Failed to find rake 11.1.2 in docker rails container

I am launching two docker containers. One with rails and one with Postgres db. Here is my docker file:

# Docs: https://docs.docker.com/compose/compose-file/ version: '2' services: db: image: postgres environment: - POSTGRES_PASSWORD=xxx rails: build: . command: rails s -p 3000 -b '0.0.0.0' volumes: - .:/app ports: - "3000:3000" links: - db depends_on: - db 

Here's the Docker file for the rails application:

 FROM ruby:2.3 RUN apt-get update RUN apt-get install -y build-essential nodejs RUN mkdir -p /app WORKDIR /app COPY Gemfile Gemfile.lock ./ RUN gem install bundler && bundle install --jobs 20 --retry 5 COPY . ./ EXPOSE 3000 ENTRYPOINT ["bundle", "exec"] CMD ["rails", "server", "-b", "0.0.0.0"] 

When I run docker-compose up , everything works fine, and I can connect to the server via the ip address from the docker machine.

When I try to connect to the container with the following command:

 docker-compose run rails console 

I get this error:

 Could not find rake-11.1.2 in any of the sources Run `bundle install` to install missing gems. 

installing the bag inside the container has no effect, and the specified stone is definitely installed. In other questions, it was mentioned that I should run bin/spring stop . So I ran:

 docker-compose run bin/spring stop 

And it returns:

 Spring is not running 

I'm still new to rubies / rails and docker. Hope someone can help me! thanks in advance

PS: Dockerfiles comments appreciated!

+7
source share
3 answers

seems like a late answer, but I will answer anyway. My educated guess is that your Gemfile.lock fixing your version of rake , which is why it complains. If you run docker build without a volume defined as in docker-compose.yml , you can easily end up like this. So give it a try.

As for your Dockerfile : if you use this for development purposes only, then this might be ok. Otherwise, you should think about starting it with another user (create a user with useradd and run the RUN tasks, etc. Accordingly). You can also use some package features, such as --path=<path> .

+1
source

We had the same problem. Despite the fact that Spring said that it does not work, my colleague pointed out to me that if I look at bin/rails , I would see that it would really work with Rails. Removing spring related gemstones in the Gemfile solved the problem.

0
source

Try this https://github.com/medicharlachiranjeevi/phusion-passenger-docker-rails.git, this will work, I created all the dependencies

0
source

All Articles