前提・実現したいこと
Railsも環境構築も初心者ですが、Docker for Macを使用してRails+postgresqlの構成で仮想環境を構築しようとしています。
以下の記事を参考に構築を行っています。
https://qiita.com/sakuraniumarete/items/f36a937412d281dfcf57
発生している問題・エラーメッセージ
docker-compose run web rails new . --force --no-deps --database=postgresql
を実行した際に、以下エラーメッセージが発生します。
Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"rails\": executable file not found in $PATH": unknown
そのため、手順通りdocker-compose build
を先に実行したのですが以下のエラーメッセージが発生します。
Step 5/13 : COPY Gemfile /myapp/Gemfile ERROR: Service 'web' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder067714777/Gemfile: no such file or directory
該当のソースコード
作業中のディレクトリ構成
Dockerfile Gemfile.lock entorypoint.sh Gemfiile docker-compose.yml
Dockerfile
1FROM ruby:2.5 2RUN apt-get update -qq && apt-get install -y nodejs postgresql-client 3RUN mkdir /myapp 4WORKDIR /myapp 5COPY Gemfile /myapp/Gemfile 6COPY Gemfile.lock /myapp/Gemfile.lock 7RUN bundle install 8COPY . /myapp 9 10# Add a script to be executed every time the container starts. 11COPY entrypoint.sh /usr/bin/ 12RUN chmod +x /usr/bin/entrypoint.sh 13ENTRYPOINT ["entrypoint.sh"] 14EXPOSE 3000 15 16# Start the main process. 17CMD ["rails", "server", "-b", "0.0.0.0"]
docker-compose.yml
docker
1version: '3' 2services: 3 db: 4 image: postgres 5 volumes: 6 - ./tmp/db:/var/lib/postgresql/data 7 web: 8 build: . 9 command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" 10 volumes: 11 - .:/myapp 12 ports: 13 - "3000:3000" 14 depends_on: 15 - db
Gemfile
1source 'https://rubygems.org' 2gem 'rails', '~>5'
entrypoint.sh
entrypoint.sh
1#!/bin/bash 2set -e 3 4# Remove a potentially pre-existing server.pid for Rails. 5rm -f /myapp/tmp/pids/server.pid 6 7# Then exec the container's main process (what's set as CMD in the Dockerfile). 8exec "$@"
Gemfile.lockは何も記述していません。
試したこと
以下の記事のAnswer1(ディレクトリの名前変更「mayapp」→「webapp」)を試しましたが同様のエラーが発生しました。
https://stackoverflow.com/questions/51200022/docker-copy-failed-to-find-gemfile-no-such-file-or-directory
補足情報(FW/ツールのバージョンなど)
バージョンは以下の通りです
Docker version 18.09.2, build 6247962
docker-compose version 1.23.2, build 1110ad01
どなたか解決方法をご教示いただけませんか?よろしくお願いいたします!!!
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/04 03:47 編集
2019/06/05 19:21