Using WordPress and MySQL Docker Containers

I am just starting out on Docker and so far it’s been fun. Here I am going to show how I used Docker WordPress and MySQL containers.

Before I delve into the details, I want to tell you that I am going to be working on Windows using SSH on Docker VM. If you want to know how to do that see this post here.

So let’s start. Open SSH console. We are going to set up MySQL first.

On your landing directory, create a folder for MySQL. I am going to call it “mysql”

Change directory to the newly created folder

We are going to use official Docker MySQL image located here. Version: 5.7

Here’s the run command I am going to use. This will map port 3306 on the container to the VM thereby allowing me to access this MySQL instance using VM’s IP address and port 3306

But for ease of use I like to put the run command inside a Shell script I name as “”.

Create “” with following contents.

Make the script executable

Then, run the script.

Of course, I had already done this before therefore you see “Already exists” messages. If you are doing this for the first time, image should get downloaded which could take 2-3 minutes depending on your internet connection.

Now I can test this MySQL instance using any Windows DB Client. Use following settings with obviously the password you set. Note, I am using “root” as login. This is only for demonstration. Obviously, you will disable it in production.


Once configured, you should be able to connect to the MySQL instance.


So far so good, let’s set up WordPress now.

Like MySQL, we are going to use official WordPress image from here.

But first, let’s create folder for wordpress. I am going to call it, simply “wordpress”

Change directory…


Here, we are linking previously created MyMySQL container with this going to beĀ  created MyWordpress container. Also, we are going to map port 80 of the container to port 80 of the VM.

Execute script

Fire up a browser on your Windows machine and go to “” and you should see WordPress Installation page!



Leave a Reply

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