In this blog post, I’ll show you how to run a complete WordPress Blog and MYSQL Database Server on Docker Containers running on Docker for Windows or a Linux Host.
NOTE: This article was replaced with a newer version.
At this stage, we can only run WordPress on Linux Containers using the official WordPress and MySQL Images.
To get this running on Windows Container Host, I’m using my Windows 10 machine with Linux Containers switched on.
Before you start, I recommend you follow this article without changing anything just to see that It works.
Download Images
To get started, I’ll download the official WordPress and MYSQL Container Images using the lines below.
docker pull wordpress

docker pull mysql

If I run the line below, I’ll see my Images
docker images

Create a MySQL Database Container
Before I create my WordPress Blog container, I’ll create a MySQL Database Server Container using the line below.
Note: Me must set the password to get MySQL to start.
I’ll note the password and Container Name for the next step where I’ll create the WordPress Container and Connect to the Database
docker run --name mysql01 -e MYSQL_ROOT_PASSWORD=Password1234 -d mysql

Create WordPress Container
Now, that My Database Server Is up and running, I’ll create my WordPress Application Container with all the MYSQL Container Details below.
docker run --name wordpress01 --link mysql01 -p 8080:80 -e WORDPRESS_DB_HOST=mysql01:3306 -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=Password1234 -e WORDPRESS_DB_NAME=wordpress -e WORDPRESS_TABLE_PREFIX=wp_ -d wordpress

Start WordPress
Now, that My Container Is running and I’m using Port Forwarding, I’ll access It using
In the home screen, I’ll continue

All I need to do now, Is settings up Site Title and Password


Done, Now I can access my WordPress blog

Conclusion
Using WordPress on Docker Containers very powerful tool for testing, development and production systems.
In my case, I’ll be using WordPress on Docker for all my development and testing purposes before moving my Blogs to Containers during 2018.
Comments
One response to “Running WordPress And MySQL On Docker Containers”
Hi –
I ran your steps as it is. however upon open localhost:8080. my browser displays
Error establishing a database connection
please advice.