Answer the question
In order to leave comments, you need to log in
Docker - how to run Apache as a user?
Hello everyone,
as soon as I add this line, Apache won't start... USER www-data
docker-compose ps -> state restarting
Dockerfile:
FROM httpd:2.4
RUN apt-get update && apt-get upgrade -y
RUN apt-get install nano -y
set default user and working directory
USER www-data
EXPOSE 80
version: '3.7'
services:
db:
image: mariadb
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
adminer:
image: adminer
restart: always
ports:
- 8080:8080
web:
image: apache
build: ./apache
depends_on:
- db
restart: always
ports:
- 80:80
volumes:
- //c/Docker/sf4/project:/usr/local/apache2/htdocs
Answer the question
In order to leave comments, you need to log in
Now, if completely on the forehead, then:
docker run --help
docker run --user XXX
FROM httpd:alpine-2.4
version: '3.7'
services:
db:
image: mariadb
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
adminer:
image: adminer
restart: always
ports:
- 8080:8080
web:
image: httpd:alpine-2.4 # поверьте, вам не нужен nano внутри контейнера! просто подключите все необходимые конфиги с хоста как volume, это правда удобно.
depends_on:
- db
restart: always
ports:
- 80:8080 #HOST:CONTAINER
volumes:
- //c/Docker/sf4/project:/usr/local/apache2/htdocs
# - скопируйте необходимые конфиги себе примерно так: "docker cp /etc/httpd/httpd.conf ." и подключите как volume
- "./httpd/httpd.conf:/etc/httpd/httpd.conf" # пример подключения конфига, где ./httpd/httpd.conf файл рядом с вашим docker-compose.yml
Is there a www-data user there?) And in general - go into the container and read the logs. business
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question