如何通过 git 在 Docker 容器中安装 gems?
How to install gems via git in Docker container?
我尝试在 docker 上开发 rails 应用程序。
docker-compose build
成功,但错误出现在docker-compose up
。
在 Gemfile 中,我使用 rails 和 github,如下所示。
gem 'rails', github: 'rails/rails'
这会导致 docker 中的错误-像这样组成
web_1 | /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/dependency.rb:310:in `to_specs': Could not find 'activesupport' (>= 4.2) among 110 total gem(s) (Gem::MissingSpecError)
web_1 | Checked in 'GEM_PATH=/usr/local/bundle:/root/.gem/ruby/2.5.0:/usr/local/lib/ruby/gems/2.5.0', execute `gem env` for more information
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1464:in `block in activate_dependencies'
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1453:in `each'
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1453:in `activate_dependencies'
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1435:in `activate'
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_gem.rb:68:in `block in gem'
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_gem.rb:67:in `synchronize'
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_gem.rb:67:in `gem'
web_1 | from /hateblocker/bin/spring:14:in `<top (required)>'
web_1 | from bin/rails:3:in `load'
web_1 | from bin/rails:3:in `<main>'
hateblocker_web_1 exited with code 1
当我像下面这样编辑 Gemfile 时,没有发生错误。
gem 'rails'
从错误消息中我发现通过 git 在容器中安装一些 gem 失败。
也许这会导致此错误。
有什么方法可以通过 git 在容器中安装 gems 吗?
Dockerfile 和 docker-compose.yml 是 here.
在docker-compose.yml
中,更改:
command: bin/rails s -p 3000 -b '0.0.0.0'
到
command: bundle exec rails s -p 3000 -b '0.0.0.0'
以便它可以 运行 rails
在 Gemfile 的上下文中。
我尝试在 docker 上开发 rails 应用程序。
docker-compose build
成功,但错误出现在docker-compose up
。
在 Gemfile 中,我使用 rails 和 github,如下所示。
gem 'rails', github: 'rails/rails'
这会导致 docker 中的错误-像这样组成
web_1 | /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/dependency.rb:310:in `to_specs': Could not find 'activesupport' (>= 4.2) among 110 total gem(s) (Gem::MissingSpecError)
web_1 | Checked in 'GEM_PATH=/usr/local/bundle:/root/.gem/ruby/2.5.0:/usr/local/lib/ruby/gems/2.5.0', execute `gem env` for more information
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1464:in `block in activate_dependencies'
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1453:in `each'
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1453:in `activate_dependencies'
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/specification.rb:1435:in `activate'
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_gem.rb:68:in `block in gem'
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_gem.rb:67:in `synchronize'
web_1 | from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_gem.rb:67:in `gem'
web_1 | from /hateblocker/bin/spring:14:in `<top (required)>'
web_1 | from bin/rails:3:in `load'
web_1 | from bin/rails:3:in `<main>'
hateblocker_web_1 exited with code 1
当我像下面这样编辑 Gemfile 时,没有发生错误。
gem 'rails'
从错误消息中我发现通过 git 在容器中安装一些 gem 失败。 也许这会导致此错误。
有什么方法可以通过 git 在容器中安装 gems 吗?
Dockerfile 和 docker-compose.yml 是 here.
在docker-compose.yml
中,更改:
command: bin/rails s -p 3000 -b '0.0.0.0'
到
command: bundle exec rails s -p 3000 -b '0.0.0.0'
以便它可以 运行 rails
在 Gemfile 的上下文中。