[英]Rails server and Rails console crash with: require': cannot load such file -- rack/protection (LoadError)
[英]Docker compose up fails with `require': cannot load such file — rack/handler/rails (LoadError)
這是我的Dockerfile:
FROM rails:4.2.4
MAINTAINER Brena Monteiro <me@monteirobrena.com>
RUN mkdir -p ~/myapp
COPY . ~/myapp
COPY Gemfile ~/myapp/Gemfile
COPY Gemfile ~/myapp/Gemfile.lock
WORKDIR ~/myapp
RUN bundle install
CMD rails s -b 0.0.0.0
還有我docker-compose.yml
:
web:
build: .
command: rails s -p 3000 -b '0.0.0.0'
ports:
- '3000:8080'
volumes:
- .:/Users/monteirobrena/myapp
如果我運行docker run
,Docker將正確啟動:
docker run -v ./:/Users/monteirobrena/docker/myapp -p 3000:8080 myapp
但是當我運行docker-compose up
我收到此錯誤:
➜ app git:(add-docker) ✗ docker-compose up
myRecreating app_web_1
myAttaching to app_web_1
web_1 | /usr/local/bundle/gems/rack-1.6.4/lib/rack/handler.rb:78:in `require': cannot load such file -- rack/handler/rails (LoadError)
web_1 | from /usr/local/bundle/gems/rack-1.6.4/lib/rack/handler.rb:78:in `try_require'
web_1 | from /usr/local/bundle/gems/rack-1.6.4/lib/rack/handler.rb:16:in `get'
web_1 | from /usr/local/bundle/gems/rack-1.6.4/lib/rack/server.rb:290:in `server'
web_1 | from /usr/local/bundle/gems/railties-4.2.3/lib/rails/commands/server.rb:125:in `print_boot_information'
web_1 | from /usr/local/bundle/gems/railties-4.2.3/lib/rails/commands/server.rb:75:in `start'
web_1 | from /usr/local/bundle/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:80:in `block in server'
web_1 | from /usr/local/bundle/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:75:in `tap'
web_1 | from /usr/local/bundle/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:75:in `server'
web_1 | from /usr/local/bundle/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
web_1 | from /usr/local/bundle/gems/railties-4.2.3/lib/rails/commands.rb:17:in `<top (required)>'
web_1 | from /usr/src/app/bin/rails:9:in `require'
web_1 | from /usr/src/app/bin/rails:9:in `<top (required)>'
web_1 | from /usr/local/bundle/gems/spring-1.6.4/lib/spring/client/rails.rb:28:in `load'
web_1 | from /usr/local/bundle/gems/spring-1.6.4/lib/spring/client/rails.rb:28:in `call'
web_1 | from /usr/local/bundle/gems/spring-1.6.4/lib/spring/client/command.rb:7:in `call'
web_1 | from /usr/local/bundle/gems/spring-1.6.4/lib/spring/client.rb:28:in `run'
web_1 | from /usr/local/bundle/gems/spring-1.6.4/bin/spring:49:in `<top (required)>'
web_1 | from /usr/local/bundle/gems/spring-1.6.4/lib/spring/binstub.rb:11:in `load'
web_1 | from /usr/local/bundle/gems/spring-1.6.4/lib/spring/binstub.rb:11:in `<top (required)>'
web_1 | from /usr/src/app/bin/spring:13:in `require'
web_1 | from /usr/src/app/bin/spring:13:in `<top (required)>'
web_1 | from bin/rails:3:in `load'
web_1 | from bin/rails:3:in `<main>'
web_1 | Exiting
myapp_web_1 exited with code
有任何想法嗎?
使用bundle exec
啟動rails服務器,如下所示:
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
ports:
- '3000:8080'
volumes:
- .:/Users/monteirobrena/myapp
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.