title: Could not find gem rails
body: <p>I am trying to build a docker container but getting the following error message:</p>
  
  <pre><code>Step 8/12 : RUN bundle binstubs bundler --force
   ---&gt; Running in ed94b127974b
  Could not find gem 'rails (&gt;= 5.1.5, ~&gt; 5.1)' in any of the gem sources listed
  in your Gemfile.
  ERROR: Service 'dockerzon' failed to build: The command '/bin/sh -c bundle binstubs bundler --force' returned a non-zero code: 7
  </code></pre>
  
  <p>I have tried with different versions of rails in my Gemfile with no success! This is what I have in my Gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
  # gem 'rails', '4.2.6'
  # gem 'rails', '&gt;= 5.1.5'
  gem 'rails', '~&gt; 5.1', '&gt;= 5.1.5'
  # Use sqlite3 as the database for Active Record
  # gem 'sqlite3'
  # Use SCSS for stylesheets
  gem 'sass-rails', '~&gt; 5.0.7'
  # Use Uglifier as compressor for JavaScript assets
  gem 'uglifier', '&gt;= 4.1.6'
  # Use CoffeeScript for .coffee assets and views
  gem 'coffee-rails', '~&gt; 4.2.2'
  # See https://github.com/rails/execjs#readme for more supported runtimes
  # gem 'therubyracer', platforms: :ruby
  
  # Use jquery as the JavaScript library
  gem 'jquery-rails'
  # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
  gem 'turbolinks'
  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
  gem 'jbuilder', '~&gt; 2.7'
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', '~&gt; 1.0.0', group: :doc
  
  # Use ActiveModel has_secure_password
  # gem 'bcrypt', '~&gt; 3.1.7'
  
  # Use Unicorn as the app server
  # gem 'unicorn'
  
  # Use Capistrano for deployment
  # gem 'capistrano-rails', group: :development
  
  group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    gem 'byebug'
  end
  
  group :development do
    # Access an IRB console on exception pages or by using &lt;%= console %&gt; in views
    gem 'web-console', '~&gt; 3.5.1'
  
    # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
    gem 'spring'
  end
  
  gem 'pg', '~&gt; 1.0.0'
  gem 'redis-rails', '~&gt; 5.0.2'
  gem 'sidekiq', '~&gt; 5.1.1'
  gem 'puma', '~&gt; 3.11.2'
  gem 'rack-timeout', '~&gt; 0.4.2'
  </code></pre>
  
  <p>and this is my Dockerfile:</p>
  
  <pre><code># Use the barebones version of Ruby 2.5
  FROM ruby:2.5-slim
  
  # Optionally set a maintainer name to let people know who made this image.
  
  # Install dependencies:
  # - build-essential: To ensure certain gems can be compiled
  # - nodejs: Compile assets
  # - libpq-dev: Communicate with postgres through the postgres gem
  RUN apt-get update &amp;&amp; apt-get install -qq -y --no-install-recommends \
        build-essential nodejs libpq-dev
  
  # Set an environment variable to store where the app is installed to inside
  # of the Docker image. The name matches the project name out of convention only.
  ENV INSTALL_PATH /dockerzon
  RUN mkdir -p $INSTALL_PATH
  
  # This sets the context of where commands will be ran in and is documented
  # on Docker's website extensively.
  WORKDIR $INSTALL_PATH
  
  # Ensure gems are cached and only get updated when they change. This will
  # drastically increase build times when your gems do not change.
  COPY Gemfile Gemfile
  
  # We want binstubs to be available so we can directly call sidekiq and
  # potentially other binaries as command overrides without depending on
  # bundle exec.
  # RUN bundle install --binstubs
  RUN bundle binstubs bundler --force
  
  # Copy in the application code from your work station at the current directory
  # over to the working directory.
  COPY . .
  
  # Provide a dummy DATABASE_URL to Rails so it can pre-compile assets.
  RUN bundle exec rake RAILS_ENV=production DATABASE_URL=postgresql://user:pass@127.0.0.1/dbname SECRET_TOKEN=dummytoken assets:precompile
  
  # Ensure the static assets are exposed through a volume so that nginx can read
  # in these values later.
  VOLUME ["$INSTALL_PATH/public"]
  
  # The default command that gets ran will be to start the Puma server.
  CMD bundle exec puma -C config/puma.rb
  </code></pre>