What would be the advantages on running dockerized WordPress ?

  • Posted on January 31, 2015
  • jpvaleryAsked by jpvalery

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 !


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.

Thanks for your reactivity buddy.

Well, the issue is that the WP droplet is set up with a LAMP where I’d like to try out a LEMP ^^’

Wouldn’t be the move to Docker be more complicated later than now ? I mean, we’re not in a hurry, and I’d prefer to set up something evolutive and reliable. Even if that means spending long hours cursing my past self over taking that decision, because it’ll be worth it on the long run :D

Thanks again for sharing your wisdom !

Transferring an existing WP can be a lot of work, and learning Docker on top of that can make it even more difficult. If you’re used to shared hosting and not very familiar yet with setting up and using a LEMP stack, it might be advisable to start with a Wordpress droplet. You can move on to Docker once you’re more confident.

I do advice you to start learning Docker at some point: the way things are looking now, the future of hosting seems to be in application containers, and Docker is leading the field. You could start out with playing with it on your local computer. There’s any number of tutorials you could try. Once you’ve got the hang of it, you can fire up a new Docker droplet and see if you get your WP working on that without transferring the domain name until you’re sure you’re ready.