#やりたい事
rails newをしたいけど、エラーになるので、解決策が知りたい。
#使用している環境
windows10 64bit
Docker Desktop for Windows
#問題が発生するまでの流れ・手順
参考にしたサイト
このページからgit cloneをして、5つのファイル(Dockerfile, docker-compose.yml, Gemfile, Gemfile.lock, entrypoint.sh)ができました。以下、ファイルの中身です。
Dockerfile
1FROM ruby:2.6.3-alpine 2 3ENV LANG=ja_JP.UTF-8 4ENV TZ=Asia/Tokyo 5ENV ROOT=/myapp \ 6 GEM_HOME=/bundle \ 7 BUNDLE_PATH=$GEM_HOME 8ENV BUNDLE_BIN=$BUNDLE_PATH/bin 9ENV PATH /app/bin:$BUNDLE_BIN:$PATH 10 11 12WORKDIR $ROOT 13 14RUN apk update && \ 15 apk upgrade && \ 16 apk add --no-cache \ 17 gcc \ 18 g++ \ 19 libc-dev \ 20 libxml2-dev \ 21 linux-headers \ 22 make \ 23 nodejs \ 24 postgresql \ 25 postgresql-dev \ 26 tzdata \ 27 yarn && \ 28 apk add --virtual build-packs --no-cache \ 29 build-base \ 30 curl-dev 31 32COPY Gemfile $ROOT 33COPY Gemfile.lock $ROOT 34 35RUN bundle install -j4 36# 不要ファイル削除 37RUN rm -rf /usr/local/bundle/cache/* /usr/local/share/.cache/* /var/cache/* /tmp/* && \ 38apk del build-packs 39 40COPY . $ROOT 41 42# Add a script to be executed every time the container starts. 43COPY entrypoint.sh /usr/bin/ 44RUN chmod +x /usr/bin/entrypoint.sh 45ENTRYPOINT ["sh", "/usr/bin/entrypoint.sh"] 46EXPOSE 3000 47 48# Start the main process. 49# CMD ["rails", "server", "-b", "0.0.0.0"]
dockercomposeyml
1version: '3' 2 3services: 4 db: 5 image: postgres:11.0-alpine 6 volumes: 7 - postgres:/var/lib/postgresql/data:cached 8 environment: 9 - TZ=Asia/Tokyo 10 ports: 11 - '5432:5432' 12 environment: 13 PGDATA: /var/lib/postgresql/data/pgdata 14 POSTGRES_USER: postgres 15 POSTGRES_PASSWORD: password 16 POSTGRES_INITDB_ARGS: '--encoding=UTF-8 --locale=ja_JP.UTF-8' 17 TZ: Asia/Tokyo 18 app: 19 build: . 20 command: ash -c "rm -f tmp/pids/server.pid && ./bin/rails s -p 3000 -b '0.0.0.0'" 21 volumes: 22 - .:/myapp:cached 23 - rails_cache:/myapp/tmp/cache 24 - bundle:/bundle:cached 25 tmpfs: 26 - /tmp 27 tty: true 28 stdin_open: true 29 ports: 30 - "3000:3000" 31 environment: 32 RAILS_ENV: development 33 NODE_ENV: development 34 DATABASE_HOST: db 35 DATABASE_PORT: 5432 36 DATABASE_USER: postgres 37 DATABASE_PASSWORD: password 38 WEBPACKER_DEV_SERVER_HOST: webpacker 39 depends_on: 40 - db 41 - webpacker 42 links: 43 - db 44 - webpacker 45 webpacker: 46 build: . 47 command: ./bin/webpack-dev-server 48 volumes: 49 - .:/myapp:cached 50 environment: 51 RAILS_ENV: development 52 NODE_ENV: development 53 WEBPACKER_DEV_SERVER_HOST: 0.0.0.0 54 tty: false 55 stdin_open: false 56 ports: 57 - '3035:3035' 58 59volumes: 60 rails_cache: 61 postgres: 62 bundle: 63
Gemfile
1source 'https://rubygems.org' 2gem 'rails', '6.0.3'
Gemfilelock
1空です。
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 "$@"
#発生している問題・エラーメッセージ
2.docker-compose run app rails new . --force --no-deps --database=postgresql --skip-bundleをしようとしたら以下のようなエラーが出ました。
[+] Building 18.3s (10/14) => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 1.08kB 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [internal] load metadata for docker.io/library/ruby:2.6.3-alpine 2.3s => [ 1/10] FROM docker.io/library/ruby:2.6.3-alpine@sha256:a546d6c5f530bbcc2d41fbf0da21d94da9f70 0.0s => [internal] load build context 0.0s => => transferring context: 254.50kB 0.0s => CACHED [ 2/10] WORKDIR /myapp 0.0s => CACHED [ 3/10] RUN apk update && apk upgrade && apk add --no-cache gcc 0.0s => CACHED [ 4/10] COPY Gemfile /myapp 0.0s => CACHED [ 5/10] COPY Gemfile.lock /myapp 0.0s => ERROR [ 6/10] RUN bundle install -j4 15.9s ------ > [ 6/10] RUN bundle install -j4: #10 2.777 Fetching gem metadata from https://rubygems.org/............. #10 4.851 Fetching gem metadata from https://rubygems.org/. #10 4.891 Resolving dependencies.... #10 5.293 Fetching rake 13.0.6 #10 15.27 marcel was resolved to 0.3.3, which depends on #10 15.27 mimemagic ------ failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c bundle install -j4]: exit code: 5
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。