Docker container builds locally but not on GitLab


The dockerfile builds locally but the GitLab pipeline fails, saying:

Step 3/8 : RUN gem install bundler rake
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/local/bundle directory.

The project strucutre is a Ruby Sinatra backend and a React frontend.

The Dockerfile looks like this

FROM ruby:3.0-alpine

# Install Dependencies
RUN apk update && apk add --no-cache build-base mysql-dev rrdtool
RUN gem install bundler rake

# Copy the files and build
WORKDIR /usr/server
COPY . .
RUN bundler install

# Run bundler
CMD ["bundle", "exec", "puma"]

I thought Docker meant was meant to solve the problem of "it runs on my machine"…

What I’ve tried

As per this post, I tried adding -n /usr/local/bundle but it did not fix the issue.

Source: Docker Questions

Categorised as continuous-integration, docker, gitlab, reactjs, ruby Tagged , , , ,


Leave a Reply

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us