Persisting a dockerized WordPress (with LAMP stack)

I’m working on moving my WordPress blogs from a traditional setup to Docker, however I’m having some trouble in understanding what is the best way to persist data.

In short, my idea is to have each blog running inside its own container (based on tutum/wordpress). During my tests I noticed that if I save any data on the blog, when I commit the container, the image does not contain such data. As far as I understood Docker is supposed to save the status of the container when committing a new image. This is what happens when I run commands or install packages on a container, but somehow doesn’t happen when I, for example, create a new post in WordPress.

Read More

I have read a bit about Docker volumes, however I don’t think having a separate data volume is very convenient, as I’d prefer having all data in a single container, which I can then move around more easily.

Is there anything I am missing? What is preventing Docker from saving new posts in WordPress?

Thank you all for your time!

Related posts

Leave a Reply

1 comment

  1. The Dockerfile for tutum/wordpress is based off tutum:lamp, which declares a volumes at /etc/mysql and /var/lib/mysql. So, if you use that image, you have volumes whether you like it or not. Because data in volumes lives outside of the Union File System, it will not be saved by a docker commit command.

    If you really don’t want to use volumes, you could write your own Dockerfile without the volume statements. However, this really isn’t going to work very well – every time you want to save the state of wordpress you would have to commit a new image, which would build on top of the last one. Apart from just being annoying and unwieldy, you will eventually hit the maximum number of layers allowed in an image.

    Instead, you’re just going to have to deal with volumes I’m afraid. This isn’t as bad as you think – you can just zip up the volume directory and unzip it into a new volume. The big advantage is you keep your mutable and changing data separate from your application code which can be updated and changed separately.