Can’t run apache2 in Docker container. I’m getting this message:
AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 192.168.80.3. Set the ‘ServerName’ directive globally to suppress this message
site | (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
site | no listening sockets available, shutting down
site | AH00015: Unable to open logs
This is my docker-compose.yml:
version: "3"
services:
site:
build:
context: .
dockerfile: ./Dockerfile
container_name: site
ports:
- "8080:80"
volumes:
- ./src:/var/www/html:delegated
depends_on:
- mysql
networks:
- laravel
mysql:
image: mysql:5.7.29
container_name: mysql
restart: unless-stopped
tty: true
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_DATABASE: homestead
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: secret
SERVICE_TAGS: dev
SERVICE_NAME: mysql
networks:
- laravel
networks:
laravel:
Dockerfile:
FROM php:7.3-apache
RUN apt-get update && apt-get install -y wget zip
RUN docker-php-ext-install pdo_mysql mbstring
RUN wget https://getcomposer.org/installer -O - -q
| php -- --install-dir=/bin --filename=composer --quiet
RUN groupadd --gid 1000 www
&& useradd --uid 1000 --gid www --shell /bin/bash --create-home www
USER www
WORKDIR /var/www/html
So, I want to work in container ‘site’ under non-root user, but apache2 does not start without root
2
Answers
The solution: add user: root to site container:
Form apache documentation – How Apache Starts
In my case I have:
ports.conf
Dockerfile
and in
docker-compose.yml