我用nginx和php:fpm设置了docker,我得到了:
"Unable to write in the cache directory" Could not create cache directory
或
"/usr/share/nginx/html/app/cache/dev/annotations".
错误。我知道这是一个常见的错误,但对Nginx来说并不陌生,在Linux上并不是很好,我似乎无法弄清楚我需要创建哪些用户以及需要创建哪些权限以及在哪里?
我尝试将以下内容添加到我的nginx:最新的dockerfile但没有运气。有什么想法吗?
RUN adduser www-data www-data
RUN usermod -u 1000 www-data
RUN chown -R www-data:www-data /usr/share/nginx/html/app/cache
RUN chown -R www-data:www-data /usr/share/nginx/html/app/logs
RUN rm -rf /usr/share/nginx/html/app/cache/*
RUN rm -rf /usr/share/nginx/html/app/logs/*
Dockerfile:
FROM nginx:latest
ADD . /usr/share/nginx/html
RUN adduser www-data www-data
RUN usermod -u 1000 www-data
RUN chown -R www-data:www-data /usr/share/nginx/html/app/cache
RUN chown -R www-data:www-data /usr/share/nginx/html/app/logs
RUN rm -rf /usr/share/nginx/html/app/cache/*
RUN rm -rf /usr/share/nginx/html/app/logs/*
ADD /docker_setup/default.conf /etc/nginx/conf.d/
ADD /docker_setup/nginx.conf /etc/nginx/
ENV TERM xterm
EXPOSE 80
Docker撰写:
version: '2'
services:
web:
# image: nginx:latest
build: .
ports:
- "8080:80"
volumes:
- .:/usr/share/nginx/html
links:
- php
volumes_from:
- php
volumes:
- ./logs/nginx/:/var/log/nginx
php:
image: php:fpm
expose:
- 9000
volumes:
- .:/usr/share/nginx/html