Bundler fails in Docker mirror service with local gem paths

I’m using a docker-compose.yml file that looks like.

version: '2'

    tty: true
    image: ruby:2.4
      - 3000:3000
      - .:/app
      - .env

    build: .
    command: bundle exec sidekiq

And sidekiq works fine and builds from the same Dockerfile info that the myapp generates. But when I add some gem dependencies in my Gemfile that require local directory access it fails.

  • Why does “bundle install --path” break when “bundle install” works?
  • bundler: command not found: rails with docker-compose on a sample project
  • Docker: Do I need to rebuild the container from scratch whenever I need to add software?
  • How to deal with Docker container dependencies properly?
  • `rails console` hangs when using vendored gems (running in docker)
  • Could not install gems on docker container
  • Adding this to Gemfile and bundle update won’t allow sidekiq to build.

    gem 'rails-assets-jplayer',   path: 'lib/gems/rails-assets-jplayer'
    gem 'rails-assets-bootstrap', path: 'lib/gems/rails-assets-bootstrap'
    gem 'rails-assets-jquery',    path: 'lib/gems/rails-assets-jquery'
    gem 'rails-assets-jquery-ui', path: 'lib/gems/rails-assets-jquery-ui'

    After adding these I get this error only from sidekiq and not from myapp (it works).

    myapp uses an image, skipping
    Building sidekiq
    Step 1/4 : FROM ruby:2.4-onbuild
    # Executing 4 build triggers...
    Step 1/1 : COPY Gemfile /usr/src/app/
     ---> Using cache
    Step 1/1 : COPY Gemfile.lock /usr/src/app/
     ---> Using cache
    Step 1/1 : RUN bundle install
     ---> Running in ccfd0fc73542
    The path `/usr/src/app/lib/gems/rails-assets-jquery-ui` does not exist.
    ERROR: Service 'sidekiq' failed to build: The command '/bin/sh -c bundle install' returned a non-zero code: 13

    I can’t figure out if the directory structure is different in sidekiq or if it really doesn’t have access to just this subfolder. Is there a way I can introspect the path that the bundle install is happening in? And more importantly; how can I get the local gems to work in this second container?

    If you plan on asking about a Dockerfile — don’t. It’s purely what docker-compose generated and hasn’t been modified. Like I said both of these docker images work if the Gemfile doesn’t have the local gems required in it.

  • What information is kept by a non-running docker container?
  • Downloading images from custom registry with go-dockerclient hangs
  • Does Docker contain the Heardbleed exploit?
  • Sending SIGTERM to all processes
  • Docker Container DNS resolution
  • Can I use docker for installing ubuntu on a Mac?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.