compose: Unable to find GemFile

Hey all,

I’m currently configuring docker-compose on my Linux Mint machine. The problem is, I’m able to build the web aspect of my project without errors. However, when it comes to running the rails server, rails console, or really anything that involves the rails command, I’m getting the following errors:

web_1 | Could not locate Gemfile or .bundle/ directory

/myapp/Gemfile not found

Any idea what’s going on here. Posting my docker-compose.yml and related files below.

Docker Version: 1.8.2 Docker Machine Version: 0.4.0 Docker Compose Version: 1.4.2

docker-compose.yml

db:
  image: postgres:9.4.1
  ports:
    - "5432:5432"

web:
  extends:
    file: common.yml
    service: webapp
  build: .
  command: bundle exec thin -D start
  ports:
      - "3000:3000"
  links:
      - db

Common.yml

webapp:
  environment:
      RAIL_ENV: development
  volumes:
      - .:/myapp

Dockerfile

FROM ruby:2.2.2

ENV LANG C.UTF-8

RUN apt-get update -qy
RUN apt-get upgrade -y
RUN apt-get update -qy
RUN apt-get install -y build-essential

# for postgres
RUN apt-get install -y libpq-dev

# for nokogiri
RUN apt-get install -y libxml2-dev libxslt1-dev

# for capybara-webkit
#RUN apt-get install -y libqt4-webkit libqt4-dev xvfb

# for a JS runtime
RUN apt-get install -y nodejs

ENV APP_HOME /myapp
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

ADD Gemfile* $APP_HOME/
RUN bundle install

ADD . $APP_HOME

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 19

Most upvoted comments

The volume is masking the contents of the image. You need to either remove volumes: - .:/srv/app or make sure that you have the bundle contents on the host as well. The Compose guides do this by running something like docker-compose run app bundler install ...

I’m leaving this comment as a signpost for others. The error message in the OP matched one I encountered while using a volume for bundled gems between containers ( api, resque, resque-scheduler etc).

I hit the same error using Fedora25 with SELinux and Win10 using docker-toolbox. For SELinux Permissive works, bundle completes in the build phase. For win10 it was due to the project being outside the Users folder. Moving it inside Users home allowed progress.

HTH

My docker-compose.yml

app:
  build: .
  command: bundle exec rails s -p 3000 -b '0.0.0.0'
  volumes:
    - .:/srv/app
  ports:
    - "3000:3000"
    - "80:80"
  links:
    - db
  env_file:
    - '.env.app'
db:
  image: postgres
  ports:
    - "5432:5432"

docker-compose goes OK

BUT

docker-compose up throws:

db_1  | LOG:  database system was interrupted; last known up at 2016-01-18 22:21:18 UTC
db_1  | LOG:  database system was not properly shut down; automatic recovery in progress
db_1  | LOG:  invalid record length at 0/1707A08
db_1  | LOG:  redo is not required
db_1  | LOG:  MultiXact member wraparound protections are now enabled
db_1  | LOG:  database system is ready to accept connections
db_1  | LOG:  autovacuum launcher started
app_1 | Could not locate Gemfile or .bundle/ directory
app_app_1 exited with code 10

I had pretty much the same error, I also posted here. For docker-machine to work on Windows, we must place project files somewhere inside C:/Users/ otherwise volumes won’t mount, leaving an empty folder.

I suppose one can add a shared folder on the docker-machine in virtualbox’s settings in case project is in a different drive, but I did not go this way. We simply moved the project to a valid place.

(Almost) same her as Colindensem, but on Win7 instead of Win10. Whole project copied to Users folder, and starting from there: problem solved. This is not an option on the long term, but for the time being i at least can run my project. (Using this as a clue, we might find a solution that will keep the app’s on the development drive)

tried that…

Could not locate Gemfile or .bundle/ directory

Still the same

My docker file is like this:


FROM ruby:2.3.0

EXPOSE  80
EXPOSE  22
ENV     RAILS_ENV   production
ENV     TERM        xterm

RUN \
        apt-get -y update \
        && apt-get install -y --force-yes software-properties-common \nginx lynx nano curl build-essential autoconf automake libass-dev libfreetype6-dev \
        && apt-get clean \
        && rm -rf /var/lib/apt/lists/*

# --------------------------------------
# BUNDLER
# --------------------------------------
WORKDIR /tmp
ADD     .               /tmp
ADD     .               /srv/app
ADD     ./Gemfile       /srv/app/Gemfile
ADD     ./Gemfile.lock  /srv/app/Gemfile.lock
#RUN     gem install rubygems-update --no-ri --no-rdoc
RUN     gem install bundle --no-ri --no-rdoc
WORKDIR /srv/app
COPY    Gemfile Gemfile
RUN     bundler install --jobs 7 --without development test
#RUN    bundle exec rake assets:precompile --trace


I would recommend trying the following:

  1. Upgrade to the latest docker-compose 1.5.0
  2. run a docker-compose rm to clear out old volumes, then do up again.

.:/myapp should work as a volume path