Docker + wsl2でrails6の環境構築を行っております。コンテナにログインし、rails new を実行しようとすると謎のエラーにはまってしまいました、、、
Traceback (most recent call last): 33: from /usr/local/bundle/bin/rails:23:in `<main>' 32: from /usr/local/bundle/bin/rails:23:in `load' 31: from /usr/local/bundle/gems/railties-6.0.3.1/exe/rails:10:in `<top (required)>' 30: from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 29: from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 28: from /usr/local/bundle/gems/railties-6.0.3.1/lib/rails/cli.rb:18:in `<top (required)>' 27: from /usr/local/bundle/gems/railties-6.0.3.1/lib/rails/command.rb:46:in `invoke' 26: from /usr/local/bundle/gems/railties-6.0.3.1/lib/rails/command/base.rb:69:in `perform' 25: from /usr/local/bundle/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch' 24: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command' 23: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/command.rb:27:in `run' 22: from /usr/local/bundle/gems/railties-6.0.3.1/lib/rails/commands/application/application_command.rb:26:in `perform' 21: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/base.rb:485:in `start' 20: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/group.rb:232:in `dispatch' 19: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:134:in `invoke_all' 18: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:134:in `map' 17: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:134:in `each' 16: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:134:in `block in invoke_all' 15: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command' 14: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/command.rb:27:in `run' 13: from (eval):1:in `create_root' 12: from /usr/local/bundle/gems/railties-6.0.3.1/lib/rails/generators/app_base.rb:161:in `create_root' 11: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/actions/empty_directory.rb:14:in `empty_directory' 10: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/actions.rb:93:in `action' 9: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/actions/empty_directory.rb:50:in `invoke!' 8: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/actions/empty_directory.rb:117:in `invoke_with_conflict_check' 7: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/actions/empty_directory.rb:52:in `block in invoke!' 6: from /usr/local/lib/ruby/2.6.0/fileutils.rb:200:in `mkdir_p' 5: from /usr/local/lib/ruby/2.6.0/fileutils.rb:200:in `each' 4: from /usr/local/lib/ruby/2.6.0/fileutils.rb:215:in `block in mkdir_p' 3: from /usr/local/lib/ruby/2.6.0/fileutils.rb:215:in `reverse_each' 2: from /usr/local/lib/ruby/2.6.0/fileutils.rb:217:in `block (2 levels) in mkdir_p' 1: from /usr/local/lib/ruby/2.6.0/fileutils.rb:239:in `fu_mkdir' /usr/local/lib/ruby/2.6.0/fileutils.rb:239:in `mkdir': Permission denied @ dir_s_mkdir - /apps/myapp (Errno::EACCES)
Dokerfile
FROM oiax/rails6-deps:latest ARG UID=1000 ARG GID=1000 RUN mkdir /var/mail RUN groupadd -g $GID devel RUN useradd -u $UID -g devel -m devel RUN echo "devel ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers WORKDIR /tmp COPY init/Gemfile /tmp/Gemfile COPY init/Gemfile.lock /tmp/Gemfile.lock RUN bundle install COPY ./apps /apps RUN apk add --no-cache openssl USER devel RUN openssl rand -hex 64 > /home/devel/.secret_key_base RUN echo $'export SECRET_KEY_BASE=$(cat /home/devel/.secret_key_base)' \ >> /home/devel/.bashrc WORKDIR /apps
Gemfile
source 'https://rubygems.org' gem 'rails', '~> 6.0.3.1'
.gitignore
/apps/* !/apps/.keep /tmp/* !/tmp/.keep docker-compose.override.yml
試したこと
ruby, railsのバージョンを確認
local のRubyの確認
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。