Hassle free WordPress in Docker

Lately, I had to reinstall WordPress on this blog. What I did was to upgrade to 5.1, but since I’m running it in Docker Swarm, I also wanted to update the image used. The issue is that the wp-config.php is stored in the root which is lost if you change the image.

Initially, I thought that using a mounted volume for wp-content folder is enough. The media and plugins are stored here. The configuration is stored in the root folder. Okay, let’s say that it’s not a big deal: we reinstall then we point to the right database. Sounds easy in theory, but in practice I experienced all kinds of errors so I had to reinstall from scratch.

Export to the rescue

At least I was pretty smart to perform an export of the whole data before venturing into this upgrade. WordPress allows you to do this very easy from the admin menu. After the reinstall, I managed to import the data back and so I have restored the posts, comments and plugins.

The only thing missing are the featured image for posts, which I need to set them back again.


The morale of this story is that running WordPress in Docker can be tricky regarding updates to newer versions. My recommendation is to have a volume mounted that points to the root of your WordPress installation. Hence, any updates you may do, can be done from the admin interface and if for whatever reason, your Docker container is reset, your files are safe and sound in the mounted volume.

Hope it’s useful for you!

Thanks for reading, I hope you found this article useful and interesting. If you have any suggestions don’t hesitate to contact me. I also invite you to share and subscribe to the newsletter by using the buttons below! Cheers  😉

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Leave a Reply

Notify of