Answer the question
In order to leave comments, you need to log in
Docker + Nginx getpwnam("www-data") problem how to solve?
In 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
...
user www-data;
pid /var/run/nginx.pid;
...
...
#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
...
2019/02/06 10:59:09 [emerg] 1#1: getpwnam("www-data") failed in /etc/nginx/nginx.conf:1
Answer the question
In order to leave comments, you need to log in
You don't have such a user - www-data. And the groups too. Add something like this to your Dockerfile:
RUN addgroup -g 1010 -S www-data && adduser -u 1010 -D -S -G www-data www-data
added, same problem
#nginx
FROM nginx:alpine
RUN addgroup -g 1010 -S www-data && \
adduser -u 1010 -D -S -G www-data www-data && \
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
2019/02/06 13:28:34 [emerg] 1#1: getpwnam("www-data") failed in /etc/nginx/nginx.conf:1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question