Tag Archives: docker

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 “run.sh”.

Create “run.sh” 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…

Create run.sh

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!


Configuring Docker SSH on Bitvise on Windows

Docker on Windows has a lot to be desired. One thing I found uncomfortable to use is the Docker Shell on Windows. As of version 1.11.2, Docker uses MINGW64 extension to provide the UNIX Shell on Windows and even then it operates on the host, i.e. the Windows machine. If you know the current architecture, Docker runs on a Linux VM on top of Windows host. Therefore, what gets typed on Docker console is eventually passed to the VM. Through wonderful Docker documentation I figured I could actually SSH directly into the VM itself, and it’s very easy.

Docker Console on Windows
Docker Console on Windows

For my SSH I use Bitvise SSH client but these steps should apply to any other client such as Putty. Docker provides SSH private key which could be used by any client.

Open Bitvise Client Key Manager, and click on “Import”. Then Navigate to “c:\users\userid\.docker\machine\machines\default” and select “id_rsa” file. Import the file and note down the Location. It should be “Global n” where n=1,2,3 etc.


Next open Bitvise SSH Client. Configure a profile with following details:


Hit login and hopefully you will be logged in!


PyCharm on Windows and Docker

I have recently started using Python and Docker. As a novice, I wanted to configure PyCharm on Windows to use my Docker Python image. Here are couple of things I had to do to successfully accomplish this:

  • Your Project folder must be inside your Windows home folder, i.e. c:\users\user. If not, PyCharm will not be able to run your Python file

2016-06-16 21_02_45-Location

  • Next, ensure that Docker is selected as a “Remote Python Interpreter”. Obviously as a prerequisite you must install Docker and pull Python image. If done correctly, PyCharm should recognize the interpreter

2016-06-16 21_01_10-ConfigureDocker

With this you should be able to run your Python code directly against Docker image. Here’s a Hello World example I ran.

2016-06-16 21_04_28-HelloWorld - [C__Users_vikc0_Python_HelloWorld] - ..._hello_world.py - PyCharm 5