Docker Compose on Windows 7: Could not locate Gemf

2019-07-15 04:56发布

问题:

I get the following error when I run the command docker-compose up

Could not locate Gemfile or .bundle/ directory
exited with code 10

Following is the code.

Note : I have added the parent directory of my code as a permanent shared folder to the VM using Oracle VM virtual box manager.

Any thoughts to resolve the issue.?

Dockerfile

FROM ruby:2.3.0
ENV HTTP_PROXY http://proxy.com:8080
ENV HTTPS_PROXY http://proxy.com:8080
RUN mkdir /student-api
WORKDIR /student-api
ADD Gemfile /student-api/Gemfile
ADD Gemfile.lock /student-api/Gemfile.lock
RUN bundle install
ADD . /student-api

Docker Compose

db:
  image: postgres
  ports:
    - "5432:5432"
web:
  build: .
  command: bundle exec rails s -p 3000 -b '0.0.0.0'
  volumes:
    - .:/student-api
  ports:
    - "3000:3000"
  links:
    - db

回答1:

You are creating the .bundle directory in the container, then masking it with the host directory , because you're using a volume:

volumes:
    - .:/student-api

You need to either run the bundle install on the host, or remove the volume from the Compose file.



回答2:

Are you mounting HOST directory within your HOME path (e.g. c:/Users/john/*).

Be advised that doing this outside HOME path does not work correctly.