Report this

What is the reason for this report?

What would be the advantages on running dockerized WordPress ?

Posted on January 31, 2015

Hi everyone,

After years of shared hosting, I’m ready to take the leap and move on to the next step :) Even though I’ve some basics in Linux, I guess that this is going to be an exciting challenge.

I’m still cramming the excellent tutorials of the community, especially the ones about LEMP and securing the VPS.

However, I see all the hype going around docker and read on a few places about running WP and MySQL in dockerized containers. And I was just wondering what the advantages would be ? Or if a LEMP stack alone would be enough ?

So, if some people have some wisdom to share, I’d be glad to learn from your experiences :)

Thanks in advance !

Cheers,



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hey !

Waoh thanks for that extensive answer !

To give you more insights : I’ll be transferring a huge WP to DO in the coming weeks. And that’ll be the only thing on that droplet.

As much as the security part is really convincing me, I’m afraid it’ll end up being more complicated for me than a classic LEMP stack considering that I’ll be transferring a pretty big website.

What’s your opinion on this ?

Well, if you’re willing: once you’ve gotten the basics of Docker down, it’s not much harder to set up your stuff in a Docker container than directly on your host. In essence, a container is an isolated miniature OS.

Why don’t you try installing Docker on your own computer and running these two commands:

docker run --name mysql -e MYSQL_ROOT_PASSWORD=some-secret-string -d mariadb
docker run --name myblog --link some-mysql:mysql -p 8080:80 -d wordpress

Then go to http://localhost:8080 and you should see a new Wordpress blog.

To run a shell inside a running container, you’d run this:

docker exec -it myblog bash

That’ll launch the command bash inside the myblog container. Once you’re inside the container, you can look around to see how things have been set up. After all, the best way to learn is by example.

Here’s the Dockerfile for the official wordpress Docker image. You can study that to see how the Wordpress container was constructed.

When you understand how things are set up inside you container, you can worry about how to expose that container to the world. If you only want to host one Wordpress blog on your server, the easiest solution would be to directly bind port 80 from the host to the Wordpress container. If you want to host multiple applications from one server, you need something like docker-gen to assign domain names to specific containers.

There are a number of advantages to using Docker over configuring a server yourself. For one, there’s convenience. Know how many steps it takes to setup a new Wordpress blog using docker? Two!

docker run --name mysql -e MYSQL_ROOT_PASSWORD=some-secret-string -d mariadb
docker run --name myblog --link some-mysql:mysql -p 80:80 -d wordpress

Of course, that’s for a pretty simple setup. This will bind the port 80 of your host system to the docker instance running Wordpress, so you can’t host anything else on the same server. But if you want, you can run any number of docker containers on a single server by setting up a reverse proxy like nginx or haproxy.

Secondly, you will gain access to the vast library of ready-to-deploy application images at the Docker registry (https://registry.hub.docker.com). The Wordpress and MariaDB images used above are examples of this. Pretty much any web application that has attracted notice now has Docker images ready for you to use.

The third is, in my opinion, neatness. Your server itself will not have a big stack installed, like LAMP: all your server needs to know is how to run docker containers. After that, you can run any number of services in containers, and they are completely separate. Want to run rails? Add a container. Django? Add a container. If you want to run three apps on different versions of Ruby, normally you’d have to do some pretty messy stuff with rbenv or rvm. Now, you can simply package your app in different containers, and you host won’t care!

And finally security: if you deploy an app with a vulnerability and hackers gain root, they will only have root inside a single docker container, and can’t get at your host system.

I’ve been looking into Docker myself recently, and was surprised at how powerful it can be. I’ve taken Wordpress blogs offline and brought new ones up in seconds, using only a single Droplet. I’ve written about my experiences: http://blog.romkevandermeulen.nl/2015/01/31/dokku-docker-server-power-control/

I hope that helps you out. I’m happy to discuss it further if you have any more questions. Let me know!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.