I moved WordPress inside a docker container



Hi all,

I migrated this website from apache barebone installation to encapsulated wordpress inside a docker container with php fpm and nginx.

This is actually a test post I am making to ensure that all is working fine, but also to provide you update about the site and what I changed.

I haven’t been active for several reasons, first of all don’t want to invest time here as at a later time want to move away from WordPress to a custom blog system.

I have a lot of topics and knowledge that can share but will do that at a later point.


For the moment, the only update is that I moved this website from one old apache webserver + wordpress to a new architecture.

My “pet server” where I host this website and some other fun projects without any commercial meaning was old school one. One apache webserver and several websites.

I modernised it last weekend and I started to use docker for splitting my pet projects into several containers, and one container having nginx as reverse proxy.

How to migrate to docker

If you want to do the same, I have some public code I created for you to reuse.

First my docker image is available at


also with a readme how to use.


After having the wordpress site in a separate docker container, I just configured my nginx configuration in proxy container to redirect traffic to the wordpress container one.

It worked partially fine at the start, beacuse wordpress was trying to load the assets via http instead of https.

The fix for that is to configure the php site to enforce ssl and the domain where the site is served.


Just adjust wp-config.php and add these lines on the top and your issue will be fixed


That was all. Now I can have several domains on a single server thanks to reverse proxy container (nginx) and having all separate sites in separated docker containers.

Not only that, but also can have sites in different programming languages and environments, as docker containers are partially isolated.

This is my first post after moving site to docker.

What went wrong after the migration ?

The first thing that I noticed was that I could not upload images and some cache errors.

That was because php-fpm runs under www-data user and the mounted volume is mounted by other user and wordpress cannot write files or directories.

One hacky fix is to login into your container and change permissions

docker-compose exec kj_wordpress /bin/bash


chown -R www-data .

This will work great but the problem is have to do everytime your container changes and it is deployed again.

A proper automated solution would be to mount the volume and specify user and group id in docker-compose.

My question is here



That was all for this time.

See you on the next ones, probably after I update to custom blog with pre-rendering. Cheers