how to deploy WordPress on Windows Azure using Docker

Step 1: Create a VM on Azure

In click the “+ new” icon at the top of the left toolbox, and choose the CoreOS Linux (Stable) image.

CoreOS VM image

Create the VM using the Resource Manager wizard. I prefer to use an SSH key instead of a weak username + password. Find the IP address of your newly created VM, you will find it in the Properties tab of your VM object

Step 2: SSH into the VM 

On Windows I use PuTTY. This will give you a shell into your CoreOS machine.

Step 3: create the docker-compose yml file

The official WordPress Docker image documentation contains an example of yml file to start a MariaDB (MySql) container and a WordPress container, linked together, with passwords already configured.

Execute these commands

  1. touch docker-compose.yml
  2. vim docker-compose.yml

Now paste the content of the yml that you can find in the documentation, and “save and exit” from vim using :wq

Step 4: install docker-compose

just run this command to download the executable, and change its permission
curl -L `curl -s | jq -r '.assets[].browser_download_url | select(contains("Linux") and contains("x86_64"))'` > /opt/bin/docker-compose
chmod +x ~/docker-compose

Step 5: run docker-compose

run this command to “compose” your containerized wordpress deployment. This will download the docker images of MariaDB and WordPress, will spin 2 configured containers, and link them together.

sudo ./docker-compose up -d

Step 6: open port 8080 on your VM

By default, you can only use port 22 to SSH into your VM. To be able to browse your WordPress site, you need to open the configuration of the “Network security group”, and create a new “inbound security rule” to allow all traffic to port 8080.

You probably want your WP site on port 80. To achieve this, in the yml file change 8080:80 to just 80:80 . This will map the port 80 of the container to the port 80 of the host.

Step 7: browse your newly created instance

Using the IPaddress of your VM on Azure, and the port defined on step 6, you can access the site you just launched!

Congrats 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *