I am running a apache2 docker container on my ubuntu box but it keeps writing logs to my host os. Details below:
samples/docker/apache2/Dockerfile
FROM php:5.6.34-apache
COPY ./sites-available/mysite.conf /etc/apache2/sites-available/mysite.conf
RUN a2dissite 000-default.conf
#RUN a2dissite default-ssl.conf
RUN a2ensite mysite.conf
with:
samples/docker/apache2/sites-available/mysite.conf:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName localhost
ServerAlias localhost
#DocumentRoot /var/www/html
DocumentRoot /var/www
ErrorLog /dev/stderr
CustomLog /dev/stdout combined
#ErrorLog ${APACHE_LOG_DIR}/error.log
#CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
that I build/run with:
samples/docker-compose.yaml:
version: '3.8'
services:
apache2-php:
container_name: apache2-php-container
image: apache2-php-image
build:
context: ./docker/apache2
ports:
- "8082:80"
But log
, run
and lock
folders are created on my host under the root user one folder above my docker-compose.yaml file:
$ ll
total 60
drwxrwxr-x 3 user user 4096 Nov 15 09:22 samples/
drwxr-xr-x 3 root root 4096 Nov 15 10:40 lock/
drwxr-xr-x 3 root root 4096 Nov 15 10:40 log/
drwxr-xr-x 3 root root 4096 Nov 15 10:40 run/
with:
├── log
│ └── apache2
│ ├── error.log
│ └── other_vhosts_access.log
I have also tried suggestions here:
Writing Apache2 Logs to stdout/stderr?
but it has no effect.
Why are those folders/files created at that location on my host and how do I configure apache2 container to only write logs inside the container and not on my host?