Michal Čihař - Improving phpMyAdmin Docker container

Improving phpMyAdmin Docker container

Since I've created the phpMyAdmin container for Docker I've always felt strange about using PHP's built in web server there. It really made it poor choice for any production setup and probably was causing lot of problems users saw with this container. During the weekend, I've changed it to use more complex setup with Supervisor, nginx and PHP FPM.

As building this container is one of my first experiences with Docker (together with Weblate container), it was not as straightforward as I'd hope for, but in the end is seems to be working just fine. While touching the code, I've also improved testing of the Docker container to tests all supported setups and to better report in case of test fails.

The nice side effect of this is that the PHP code is no longer being executed under root in the container, so that should make it more sane for production use as well (honestly I never liked this approach that almost everything is executed as root in Docker containers).

Comments

Damian Dlugosz wrote on Aug. 29, 2016, 9:51 p.m.

If you run the internal php's server on port 8080, then you can run as www-data user, without the need for root privilegies, and don't have the nginx overhead.
Then if the user prefer, he can bind the port 8080 to 80 on the host.

What do you think?

wrote on Aug. 29, 2016, 10:25 p.m.

Well the motivation was mostly to get rid of the builting PHP server as it causes troubles with bigger requests which it doesn't seem to handle reliably. So changing user was mostly side effect here, though welcome. Honestly I don't think the nginx overhead is noticeable, on the other side it serves faster static files.

wrote on Aug. 31, 2016, 12:57 p.m.

I'm not sure that most containers execute their content as root; but I guess there are probably studies of published Dockerfiles on github or whatever. The ones I work on for $dayjob all expect to be run as a random, non-priviledged UID; I think that's quite common in production.

Do you use supervisord just to deal with reaping zombie processes?

wrote on Aug. 31, 2016, 1:12 p.m.

Supervisor is there to startup PHP-FPM and nginx. I'm not sure what's best approach, but this seems to be quite commonly used.