私人gem没有安装在docker上

我正在尝试与docker运行rails应用程序。 github的ssh url安装了几个gem,如下所示:

的Gemfile

gem 'swagger-docs', :git => 'git@github.com:xyz/swagger-docs.git', :branch => 'my_branch' 

我已经在Docker中添加了keys ,可以克隆所需的repo并从git安装gem。

Dockerfile

 RUN mkdir -p /root/.ssh COPY ./id_rsa /root/.ssh/id_rsa RUN chmod 700 /root/.ssh/id_rsa RUN ssh-keygen -f /root/.ssh/id_rsa -y > /root/.ssh/id_rsa.pub RUN ssh-keyscan github.com >> /root/.ssh/known_hosts 

当我构build它(其中包括bundle install ),一切顺利,图像成功构build。 但是,当我运行docker-compose up ,它会给出以下错误

 /usr/local/bundle/gems/bundler-1.9.2/lib/bundler/source/git/git_proxy.rb:155:in `allowed_in_path': The git source git@github.com:xyz/swagger-docs.git is not yet checked out. Please run `bundle install` before trying to start your application (Bundler::GitError) 

尝试在您的Gemfile中用httpsreplacegit,即

  gem 'swagger-docs', git: 'https://github.com:xyz/swagger-docs.git', branch: 'my_branch' 

…或者在运行bundle install之前将其添加到您的Dockerfile中:

  RUN git config --global url."https://".insteadOf git:// 

如果什么都行不通,那么就运行bundle install两次,即

  ... RUN gem install bundler && bundle install CMD bundle install && rails s -p 3000 -b 0.0.0.0