2015-11-06 185 views
3

我想使用docker部署rails應用程序。 我跟着官方教程做的事:如何使用Dockerfile文件運行軟件包安裝

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 

我的搬運工,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 

我跑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 

有什麼不對?

+0

你可以添加一個'出口LANG = C.UTF-8'(在https://github.com/koken/docker-koken-lemp/blob/master/Dockerfile#L12,HTTP後: //www.stackoverflow.com/a/14840029/6309) – VonC

+0

@VonC謝謝。你是對的。我補充說。有用!你可以把它寫下來作爲答案嗎?我會接受它。 – scho

回答

3

綜觀 「bundle install error 「invalid byte sequence in US-ASCII (ArgumentError)」」 類似的錯誤,一個選擇是廣告的Dockerfile:

export LANG=C.UTF-8 

this Dockerfile例如。

# Install required packages 
# LANG=C.UTF-8 line is needed for ondrej/php5 repository 
RUN \ 
    export LANG=C.UTF-8 && \ 
    ... 
+0

但這還不夠。新問題是:'sidekiq_1 | /usr/local/bundle/gems/bundler-1.10.6/lib/bundler/source/git/git_proxy.rb:155:in'allowed_in_path':git source git://github.com/guard/guard-test .git尚未檢出。在嘗試啓動應用程序(Bundler :: GitError)之前,請運行'bundle install'。 – scho

+0

@scho你可以用你的Dockerfile和錯誤信息提出一個新的問題嗎? – VonC

+0

是的。我在這裏問:http://stackoverflow.com/questions/33564984/how-to-install-guard-test-with-docker – scho

相關問題