2017-04-02 162 views
0

我已經用Docker組合Docker化了一個非常簡單的Rails 5應用程序(及其PostgreSQL數據庫)。當我在本機運行它,它工作正常,但如果我運行的泊塢容器內,並轉到主頁,我收到以下錯誤:Rails在Docker容器中運行時找不到臨時目錄

web_1 | ActionView::Template::Error (could not find a temporary directory): 
web_1 |  9:  <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> 
web_1 |  10:  <%= csrf_meta_tags %> 
web_1 |  11: 
web_1 |  12:  <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 
web_1 |  13:  <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 
web_1 |  14:  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
web_1 |  15: </head> 
web_1 | 
web_1 | app/views/layouts/application.html.erb:12:in `_app_views_layouts_application_html_erb__1331678602890151203_70235895526140' 
web_1 | Rendering /usr/local/bundle/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout 
web_1 | Rendering /usr/local/bundle/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/_source.html.erb 
web_1 | Rendered /usr/local/bundle/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (6.5ms) 
web_1 | Rendering /usr/local/bundle/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb 
web_1 | Rendered /usr/local/bundle/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.6ms) 
web_1 | Rendering /usr/local/bundle/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb 
web_1 | Rendered /usr/local/bundle/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.1ms) 
web_1 | Rendered /usr/local/bundle/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (35.4ms) 

我在其他職位讀,它可能取決於關於容器內/tmp目錄的權限,所以我給了它完全的權限,我也試着指定容器的TMPDIR目錄,但它沒有奏效。

任何想法?

回答

0

有過同樣的問題,我認爲你的碼頭根不是'/ var/lib/docker',而是位於文件系統樹的其他地方。

在我的案例中,docker root位於使用NTFS格式化的外部SSD上。但是,該文件系統不支持'/ tmp /'下的臨時目錄所需的權限。所以我調整了磁盤大小,創建了一個額外的EXT4分區,並配置了docker將其數據存儲在該分區上。這解決了這個問題。

如果這不起作用嘗試使用以下命令: 使用chmod + T/tmp目錄 例如: 搭配chmod + T的/ var/lib中/泊塢窗/ tmp目錄