I'm trying to run a RoR project without root user on docker. I'm using the official ruby image and when I execute bundle install
with a non root user everything goes okay, but when I run rails s -b '0.0.0.0'
or bundle exec rails s -b '0.0.0.0'
I get this error:
/usr/local/bundle/gems/bootsnap-1.3.2/lib/bootsnap/compile_cache/iseq.rb:37:in `fetch': Permission denied - bs_fetch:atomic_write_cache_file:open (Errno::EACCES)
Here is my Dockerfile:
FROM ruby:2.6.3
COPY controleGarrafao/ /home/docker/controleGarrafao
RUN apt-get update -qq && apt-get install sudo
WORKDIR /home/docker/controleGarrafao
RUN chmod +x /usr/bin/docker_entrypoint.sh
RUN chmod 777 /usr/local/bin/bundle
RUN useradd -m docker && echo "docker:docker" | \
chpasswd
RUN echo "docker ALL=(ALL:ALL) NOPASSWD: ALL" | \
tee -a /etc/sudoers
RUN chmod 777 /home/docker
USER docker
RUN bundle install
EXPOSE 3000
Can someone help me with this?
It seems like the problem is with the gem bootsnap
as your error message indicates.
If you look in the bootsnap documentation you see this:
Note that bootsnap writes to tmp/cache, and that directory must be writable. Rails will fail to boot if it is not. If this is unacceptable (eg you are running in a read-only container and unwilling to mount in a writable tmpdir), you should remove this line or wrap it in a conditional.
"this line" refers to require 'bootsnap/setup'
in config/boot.rb
So you either need to make sure the tmp/cache directory is writeable in your container or remove the the bootsnap line from config/boot.rb
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.