New to docker, I have been trying to use it with my rails project but haven't been able to start it up.
Tried changing ruby versions, and searching the web, but most questions involved deploying the app to heroku, which is not my case.
Docker file:
FROM ruby:2.4.1
RUN mkdir /zssn
WORKDIR /zssn
COPY Gemfile /zssn/Gemfile
COPY Gemfile.lock /zssn/Gemfile.lock
RUN gem install bundler
RUN bundle --version
RUN bundle install
COPY . /zssn
CMD ["rails", "server"]
docker-compose-yml
version: '3'
services:
web:
build: .
command: rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/zssn
ports:
- "3000:3000"
docker build . --no-cache, seems to be working fine when running the bundler command to install it.
---> Running in d4650608f428
Successfully installed bundler-2.0.1
Any ideas?
Ruby image comes with installed bundler
.
Environment variable BUNDLER_VERSION
is set to preinstalled version of bundler
by default. Even if you uninstall this version, bundle
will check for this environment variable and
raise error "You must use Bundler 2 or greater with this lockfile" if there is a v1/v2 mismatch
Ensure that your Gemfile.lock
bundled with needed version:
BUNDLED WITH
2.1.4
If you have another version, you can upgrade your application to the latest installed version of Bundler by running bundle update --bundler
https://bundler.io/man/bundle-update.1.html
In Dockerfile
override environment variable BUNDLER_VERSION
to needed version of bundler and install it:
ENV BUNDLER_VERSION=2.1.4
RUN gem update --system && \
gem install bundler:2.1.4 && \
bundle install
I think you need to either upgrade to a ruby image that comes with bundler 2 (e.g. FROM ruby:2.6.3
) or rebundle your Gemfile.lock
with the bundler version you want to use. Or at least that's what worked for me.
It did not work to tweak the environment variables as suggested by the Bundler guides.
This github issue makes me think this is expected behavior, but I could be totally wrong.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With