sch*_*cho 5 ruby-on-rails docker
我想使用docker来部署rails应用程序.我按照官方教程做了:
https://docs.docker.com/compose/rails/
但似乎我不幸运.
我的Dockerfile
FROM ruby:2.2.2
RUN apt-get update -qq && apt-get install -y build-essential
# for mysql
RUN apt-get install -y mysql-client libmysqlclient-dev
# for a JS runtime
RUN apt-get install -y nodejs
ENV APP_HOME /myapp
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ADD Gemfile $APP_HOME/Gemfile
ADD Gemfile.lock $APP_HOME/Gemfile.lock
RUN bundle install
ADD . $APP_HOME
Run Code Online (Sandbox Code Playgroud)
我的docker-compose.yml
db:
image: mysql
ports:
- "3306:3306"
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/myapp
ports:
- "3000:3000"
links:
- db
Run Code Online (Sandbox Code Playgroud)
跑完后docker-compose build,它显示:
...
Fetching git://github.com/guard/guard-test.git
/usr/local/bundle/gems/bundler-1.10.6/lib/bundler/ui/shell.rb:94:in `[]': invalid byte sequence in US-ASCII (ArgumentError)
from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/ui/shell.rb:94:in `strip_leading_spaces'
from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/ui/shell.rb:99:in `word_wrap'
from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/ui/shell.rb:85:in `tell_me'
from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/ui/shell.rb:31:in `error'
from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/friendly_errors.rb:12:in `rescue in with_friendly_errors'
from /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/friendly_errors.rb:7:in `with_friendly_errors'
from /usr/local/bundle/gems/bundler-1.10.6/bin/bundle:18:in `<top (required)>'
from /usr/local/bundle/bin/bundle:23:in `load'
from /usr/local/bundle/bin/bundle:23:in `<main>'
ERROR: Service 'web' failed to build: The command '/bin/sh -c bundle install' returned a non-zero code: 1
Run Code Online (Sandbox Code Playgroud)
怎么了?
查看“ bundle install error \xe2\x80\x9cinvalid byte order in US-ASCII (ArgumentError)\xe2\x80\x9d ”中的类似错误,一种选择是添加到 Dockerfile:
\n\nexport LANG=C.UTF-8\nRun Code Online (Sandbox Code Playgroud)\n\n例如,请参阅此 Dockerfile 。
\n\n# Install required packages\n# LANG=C.UTF-8 line is needed for ondrej/php5 repository\nRUN \\\n export LANG=C.UTF-8 && \\\n ...\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
4730 次 |
| 最近记录: |