Docker Community Forums

Share and learn in the Docker community.

How to update Wordpress from docker


(Thejoeyo) #1

I’m very new to Docker. Is it possible to update wordpress and plugins directly from within Docker (instead of doing so from the wordpress admin page)? I’m running the tutum/wordpress image.

Thanks in advance!


(Andy Rothfusz) #2

Could you tell us more about why you’d like to update WordPress from Docker instead of the WordPress admin page?

If the main reason is to make the update permanent, you could use the admin page to do the update, then docker commit the container to be a new image. That should preserve any changes you’ve made.

I don’t know WordPress well enough to tell you how to install updates without running it – that’s more of a WordPress question than a Docker question. Once you know how to get the updates in place, you can add those steps to a Dockerfile, starting with FROM tutum/wordpress or FROM wordpress (for the official Docker version)


(Thejoeyo) #3

I’ve been recently put in charge of managing multiple WordPress installs on several servers. I’m testing migrating them into docker, primarily for better sandboxing between sites. The other advantages of docker, including being able to easily push to a cloud-based docker solution would be nice as well. We need to be able to do the docker equivalent of scripting updates, so that we can update all of our sites at once. Perhaps something like building my own master image, based off of tutum’s, update the master, and then push it out to the rest. But then how would I manage the different files and plugins that are going to be unique to each site??? Anyways, I’ve got a lot of testing ahead of me, and I’m just getting started.
My current problem is: I’m struggling with understanding where my site is. I found a wordpress folder in a bunch of directories inside /var/lib/docker:
Example: /var/lib/docker/vfs/dir/18a071612058b0bcf93b8742414a7d2f6ac57aea225cc8556ea1bb18fa96736b/wordpress
However, there’s like 6 of these, each with their own ridiculouslylongrandomfoldername/wordpress. Normally to update wordpress from the server, you can do something like:

$ cd /tmp
$ wget http://wordpress.org/latest.zip
$ unzip latest.zip
$ cd /var/www/html/<SiteName>
$ cp -avr /tmp/wordpress/* .
$ rm -rf /tmp/wordpress /tmp/latest.zip

But I can’t find a directory structure that looks anything like /var/www/html/. I’m not entirely sure what I’m missing.


(Sabin Basyal) #4

When you are looking into /var/lib/docker/...., you are looking into Docker daemon. You should NOT update any of those files. Your site will be inside your Docker container. One way of updating your Wordpress is by making changes in Dockerfile, from which you build the image. You may use the Dockerfile shown below:

FROM tutum/wordpress
RUN cd /tmp \ 
	&& apt-get update -y \
	&& apt-get install wget -y \
	&& apt-get install zip -y \
	&& wget http://wordpress.org/latest.zip \ 
	&& unzip latest.zip \ 
	&& cp -avr /tmp/wordpress/* /var/www/html/. \ 
	&& rm -rf /tmp/wordpress /tmp/latest.zip

EXPOSE 80 3306
ENTRYPOINT ["/run.sh"]

Build the image out of this docker file : docker build -t <user>/<repo>:<tag> .
Then run the container from that image: docker run -d -p <any-port>:80 <user>/<repo>:<tag>

Another method of updating your Wordpress would be running the container through docker run -d -p <portA>:<portB> <your-wordpress-image>:<tag>
a. make changes via admin page. Then do docker commit to this container to be a new image. OR
b. docker exec -it <container-id> /bin/bash and execute your steps manually over terminal and do the docker commit to save it to a new image.
Note: you must be careful with the permission issues when you overwrite the files
The standard method would be to use the Dockerfile.