权限被拒绝@ rb_sysopen - log / application.log(Errno :: EACCES)

时间:2016-07-19 08:56:32

标签: ruby-on-rails-4 nginx docker passenger docker-compose

您好我正在使用docker使用phusion / passenger图像部署我的rails应用程序。这是我的Dockerfile

FROM phusion/passenger-ruby22:0.9.19

# set correct environment variables
ENV HOME /root
ENV RAILS_ENV production

# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]

# Expose Nginx HTTP service
EXPOSE 80

# Start Nginx / Passenger
RUN rm -f /etc/service/nginx/down

# Remove the default site
RUN rm /etc/nginx/sites-enabled/default

# Add the nginx site and config
ADD nginx.conf /etc/nginx/sites-enabled/nginx.conf
ADD rails-env.conf /etc/nginx/main.d/rails-env.conf

# Let ensure these packages are already installed
# otherwise install them anyways
RUN apt-get update && apt-get install -y build-essential \
                                         nodejs \
                                         libpq-dev

# bundle gem and cache them
WORKDIR /tmp
ADD Gemfile /tmp/
ADD Gemfile.lock /tmp/
RUN gem install bundler
RUN bundle install

# Add rails app
ADD . /home/app/webapp
WORKDIR /home/app/webapp


RUN touch log/delayed_job.log log/production.log log/

RUN chown -R app:app /home/app/webapp
RUN RAILS_ENV=production rake assets:precompile

# Clean up APT and bundler when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

我收到tmplog个文件的权限问题。

web_1 | [ 2016-07-19 08:45:12.6653 31/7ff812726700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/app/webapp: An error occurred while starting up the preloader.
web_1 |   Error ID: 42930e85
web_1 |   Error details saved to: /tmp/passenger-error-9DeJ86.html
web_1 |   Message from application: Permission denied @ rb_sysopen - log/logentries.log (Errno::EACCES)
web_1 |   /usr/lib/ruby/2.2.0/logger.rb:628:in `initialize'
web_1 |   /usr/lib/ruby/2.2.0/logger.rb:628:in `open'
web_1 |   /usr/lib/ruby/2.2.0/logger.rb:628:in `open_logfile'
web_1 |   /usr/lib/ruby/2.2.0/logger.rb:584:in `initialize'
web_1 |   /usr/lib/ruby/2.2.0/logger.rb:318:in `new'
web_1 |   /usr/lib/ruby/2.2.0/logger.rb:318:in `initialize'
web_1 |   /var/lib/gems/2.2.0/gems/le-2.7.2/lib/le/host/http.rb:37:in `new'
web_1 |   /var/lib/gems/2.2.0/gems/le-2.7.2/lib/le/host/http.rb:37:in `initialize'

我试图给chmod -R 665/775/777 log/但仍然没有解决问题。

由于

1 个答案:

答案 0 :(得分:0)

首先重新排列您的行RUN RAILS_ENV=production rake assets:precompile然后RUN chown -R app:app /home/app/webapp(在您的佣金任务之后)所以,它应该是这样的:

RUN RAILS_ENV=production rake assets:precompile RUN chown -R app:app /home/app/webapp