Share this post on:

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.

Conclusion

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  😉

Share this post on:
Avatar afivan

Author: afivan

Enthusiast adventurer, software developer with a high sense of creativity, discipline and achievement. I like to travel, I like music and outdoor sports. Because I have a broken ligament, I prefer safer activities like running or biking. In a couple of years, my ambition is to become a good technical lead with entrepreneurial mindset. From a personal point of view, I’d like to establish my own family, so I’ll have lots of things to do, there’s never time to get bored 😂

Leave a Reply