ruby-on-rails-4 - 权限被拒绝 @ rb_sysopen - 日志/application.log (Errno::EACCES)

标签 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/ 仍然没有解决问题。

谢谢

最佳答案

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

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

关于ruby-on-rails-4 - 权限被拒绝 @ rb_sysopen - 日志/application.log (Errno::EACCES),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38453813/

相关文章:

ruby-on-rails - 为什么 ActiveRecord 在引发 StatementInvalid 错误后返回一个空数组?

Mysql2::错误:where 子句中的未知列

ruby-on-rails - 使用特定 json 键上的 Postgresql json 列过滤 ActiveAdmin

docker - 如何在带有很多引号的Windows Docker容器中执行WMI查询?

linux - bash 脚本中的自动 docker 登录

docker - VM上的Docker NGINX反向代理502错误网关

ruby-on-rails - 使用 json.parse 更新哈希数组中的值

ssl - Nginx 不提供中间证书

node.js - 在后端使用 Erlang + 一些其他语言

来自 JWT token 的解码值限制 NGINX 速率