Migrating Wordpress to a Load Balanced Ghost Docker

Migrating Wordpress to a Load Balanced Ghost Docker

I am always stiving to be different and play with new technologies. So what is the next step? Well since Docker is the hot topic and I am keen to learn more so I decided to dive in head first.

This site BrianChrister.io is hosted with Digital Ocean on an Ubuntu droplet with NGINX and Wordpress on top. Nothing quite out of the ordinary besides making it a multi-site Wordpress with NGINX.

The Mission

Build a [Docker](http://docker.com) based system that is load balanced behind a NGINX Proxy. Instead of migrating Wordpress into Docker containeres I decided to also switch to [Ghost CMS](https://github.com/tryghost/Ghost) as it is running Node.js and it seemed like a very interesting project.

Getting from A --> B

So first we need to lay down the ground work. The great thing about Docker is the amount of pre-configured images available. Simply install them and BAM! You're running.
  1. I'm using Digital Ocean so I spun up a new Droplet with Docker already installed. So easy! If you don't have Digital Ocean which you should then RTFM

  2. Install the NGINX proxy by typing docker pull jwilder/nginx-proxy
    The image provided by Jwilder is an amazing peice of kit. It is an NGINX reverse proxy that monitors docker containers via the API. Once a docker container starts with the -e VIRTUAL_HOST=www.example.com variable it assigns it to the proxy automagically.

  3. Once the image is installed fire it up. docker run -d -p 80:80
    -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy

  4. Next I installed the Docker Ghost image docker pull dockerfile/ghost

  5. Time to start firing up Ghost containers. docker run -e VIRTUAL_HOST=www.example.com
    -v /localhost/directory --name container_name
    -d -p 49154:2368 -v ~/blog:/ghost-override dockerfile/ghost which will pull the Ghost image from the registry and fire it up

  6. I then repeated step 5 and renamed the container and incremented the port number by 1.

Check out Stack Overflow on how to configure your Ghost containter to store the data locally in a seperate Docker container.

Conclusion

Bam! Now you have 2 Docker containers load balanced behind a reverse proxy.

Follow me

If you liked this article be sure to Follow Me on Twitter to stay updated!