В Dockerfile
#nginx
FROM nginx:alpine
RUN touch /var/run/nginx.pid && \
chown -R www-data:www-data /var/run/nginx.pid && \
chown -R www-data:www-data /var/cache/nginx
USER www-data
VOLUME /var/www
...
в nginx.conf
user www-data;
pid /var/run/nginx.pid;
...
В docker-compose.yml
...
#Nginx Service
nginx:
image: nginx:alpine
container_name: nginx
restart: unless-stopped
tty: true
ports:
- "80:80"
- "443:443"
volumes:
- ./www:/var/www
- ./nginx/:/etc/nginx/
- ./log/nginx/:/var/log/nginx/
- ./opt/:/opt/
networks:
- app-network
...
В процессе запуска в логах nginx:
2019/02/06 10:59:09 [emerg] 1#1: getpwnam("www-data") failed in /etc/nginx/nginx.conf:1
Измучился... Помогите!