2017-03-22 7 views
0

更新:services: app: volumesの中の[0121]の問題を「- groupy-gemcache:/usr/local/bundle」に絞りました。私がそれを取り除くと、コンテナはうまく動作しますが、おそらく私はローカルの宝石のキャッシュを失うでしょう。docker +のバンドルロックでは、宝石をインストールできません(Solved-docker CMDとENTRYPOINT)

tldrは:ドッキングウィンドウ・コンビルドを実行した後、物事は大丈夫に見えるが、私は私のgemfileに何かを追加する場合、私は私の実行中のドッキングウィンドウのコンテナ内の任意のgembundleを実行することはできません。例えば、docker-compose build && docker-compose run app bash後:

[email protected]:/src# bundle check 
The Gemfile's dependencies are satisfied 
[email protected]:/src# echo 'gem "hello-world"' >> Gemfile 
[email protected]:/src# bundle 
Could not find gem 'hello-world' in any of the gem sources listed in your Gemfile. 
Run `bundle install` to install missing gems. 
[email protected]:/src# bundle install 
Could not find gem 'hello-world' in any of the gem sources listed in your Gemfile. 
Run `bundle install` to install missing gems. 
[email protected]:/src# gem 
Could not find gem 'hello-world' in any of the gem sources listed in your Gemfile. 
Run `bundle install` to install missing gems. 
[email protected]:/src# gem env 
Could not find gem 'hello-world' in any of the gem sources listed in your Gemfile. 
Run `bundle install` to install missing gems. 

私はまだドッキングウィンドウとかなり初心者だけど、私はまだgitのために、そのGemfile.lockを犯しながら、完璧な構築することができますdockerfile、キャッシュ宝石やアップデートを設定しようとしてきました[これは実際には完璧ではないかもしれませんし、私はそこに提案に公開しているかもしれません。私の使用例では、レールアプリケーションとサイドキック作業者の画像とポストグル画像と赤目画像のドッキング用ファイルを使用しています。herehereの設定と非常に似ています。

マイDockerfile [いくつかのものは、私は上記のチュートリアルから石畳ことをコメントアウト:

FROM ruby:2.3 
    ENTRYPOINT ["bundle", "exec"] 
    ARG bundle_path 
    # throw errors if Gemfile has been modified since Gemfile.lock 
    # RUN bundle config --global frozen 1 
    ENV INSTALL_PATH /src 
    RUN mkdir -p $INSTALL_PATH 
    WORKDIR $INSTALL_PATH 



    # Install dependencies: 
    # - build-essential: To ensure certain gems can be compiled 
    # - nodejs: Compile assets 
    # - npm: Install node modules 
    # - libpq-dev: Communicate with postgres through the postgres gem 
    # - postgresql-client-9.4: In case you want to talk directly to postgres 
    RUN apt-get update && apt-get install -qq -y build-essential nodejs npm libpq-dev postgresql-client-9.4 --fix-missing --no-install-recommends && \ 
    rm -rf /var/lib/apt/lists/* 

    COPY app/Gemfile app/Gemfile.lock ./ 

    # Bundle and then save the updated Gemfile.lock in our volume since it will be clobbered in the next step 
    RUN echo $bundle_path && bundle install --path=$bundle_path && \ 
    cp Gemfile.lock $bundle_path 

    # ./app contains the rails app on host 
    COPY app . 

    # Unclobber the updated gemfile.lock 
    RUN mv $bundle_path/Gemfile.lock ./ 

    CMD ["./script/start.sh"] 

ドッキングウィンドウ-compose.yml:

version: '2' 
volumes: 
    groupy-redis: 
    groupy-postgres: 
    groupy-gemcache: 

services: 
    app: 
    build: 
     args: 
     bundle_path: /usr/local/bundle 
     context: . 
     dockerfile: Dockerfile 
    command: "./script/start.sh" 
    links: 
     - postgres 
     - redis 
    volumes: 
     - ./app:/src 
     - groupy-gemcache:/usr/local/bundle 
    ports: 
     - '3000:3000' 
    env_file: 
     - .docker.env 
    stdin_open: true 
    tty: true 

答えて

0

うわー、私はそれを考え出しました。問題は、this article on CMD vs ENTRYPOINTの最後に説明されているように、ENTRYPOINT dockerfileコマンドから来ていました。

ENTRYPOINT ["bundle", "exec"]の結果がCMD ["./script/start.sh"]またはdocker-compose run app bashであると私はbundle exec 'bash'のようなコマンドを実行したと考えています。私はdockerfileからエントリポイントを削除し、上記のようにシェルに入り、手動でbundle exec 'bash'を実行して、私がバンドルやgemコマンドを実行できないサブシェルに着陸したことを確認してください。exitを2回残してください。

関連する問題