在运行Docker时,git源码还没有被检出
当我尝试从GitHub使用Gem时,我正面临着一个错误。 我在Gemfile中有以下内容:
# Gemfile source 'https://rubygems.org' ruby '2.3.1' gem 'sinatra' gem 'rack' gem 'puma' group :development do gem 'byebug' gem 'rack-test' gem 'rerun', github: 'alexch/rerun', branch: 'master' end
当我从Dockerfile
运行bundle install
,它会使用如下消息:
... Installing sinatra 1.4.6 Installing listen 3.1.5 (was 3.0.6) Using rerun 0.11.0 from git://github.com/alexch/rerun.git (at master@3e4c486) Bundle complete! 6 Gemfile dependencies, 14 gems now installed. ...
但是,当我去启动容器时,我得到:
The git source git://github.com/alexch/rerun.git is not yet checked out. Please run `bundle install` before trying to start your application
我见过类似的问题,但与Docker无关。
原来我能find问题。 问题与我的Gemfile被用来构buildDocker镜像有关。
我没有在本地运行一个bundle install
命令,导致Gemfile.lock
不被更新。 一旦我运行命令,下面的内容被添加到我的Gemfile.lock
:
@@ -1,14 +1,20 @@ +GIT + remote: git://github.com/alexch/rerun.git + revision: 3e4c486304be406cb86180ef70ec24e9ae055ce4 + branch: master + specs: + rerun (0.11.0) + listen (~> 3.0)
原来,这是我所需要的。 一旦我有更新的文件,重build图像和运行容器一切按预期工作与bundle exec rerun
。 所以赶上了,我正在使用Gemfile.lock
来帮助caching/版本locking,但没有保持与我的Gemfile
更新。