I do volunteer work on a WordPress site for our local non-profit radio station, and with a total website overhaul in the works I decided to set up WordPress with Docker and Visual Studio Code's Remote Development features since I enjoy that setup so much in my day job doing Python/Django development.
It's all working OK with the usual environment-specific tweaks, and when I run docker-compose up from a terminal it runs fine.
When I run things in VS Code's remote development environment, however, it doesn't start Apache automatically. That isn't a huge deal, but when I try to start Apache in a terminal in VS Code by running apache2 -D FOREGROUND
I get this error:
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot
If i run source /etc/apache2/envvars
that fixes the issue, so not a huge deal and solvable in launch.json I would think, but I was curious about why there's that difference between running docker-compose up in a terminal on my host OS as compared to what VS Code is doing.
Thanks for any ideas anyone might have.
I also encountered same problem. This is a typical Ubuntu problem where the /etc/apache2/envvars file needs to be sourced before apache2 can start properly.
To fix this just see the content of envars file (cat /etc/apache2/envvars), it's output will show you environment variables. Add them to your Dockerfile. In my case, I added below environment variables in my Dockerfile.
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_PID_FILE /var/run/apache2/apache2.pid
ENV APACHE_RUN_DIR /var/run/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_LOG_DIR /var/log/apache2
Use this image to start you container