Docker WordPress

Docker Wordpress

October 23, 2017

I have been using with Docker for a while now. Mostly for running isolated Docker WordPress and Docker Magento 2 development environment. With it’s docker-compose you can really automate/optimize the process of creating a new isolated development environment for a new project. If we take for example WordPress, we need 3 containers:

  1. wordpress:latest (container with the latest available wordpress instance itself)
  2. mysql:5.7 (container with Mysql version 5.7)
  3. phpmyadmin/phpmyadmin:latest (container with holding the phpmyadmin instance)

The last one is optional. If you are using Mysql Workbench, you don’t need to include it.

Setting up Docker WordPress development environsment

Let’s say you are new to docker-compose. The first thing you neeed to do is to create a new folder

mkdir test
cd test

Inside this folder create a new file docker-compose.yml

version: '3'

     image: mysql:5.7
       - db_data:/var/lib/mysql
     restart: always
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

       - db
     image: wordpress:latest
       - "80:80"
     restart: always
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
         - type: bind
           source: //c/Users/deanpodgornik/Documents/Kitematic/www_wordpress_1/var/www/html<br> 
           target: /var/www/html<br>

     image: phpmyadmin/phpmyadmin:latest
       - 8181:80
       MYSQL_USERNAME: wordpress
       MYSQL_ROOT_PASSWORD: wordpress
       PMA_HOST: db


In this file we define all of the three containers (mysql, wordpress and phpmyadmin). To bring those containers (a.k.a Docker WordPress development environment) to life, just type the following command:

docker-compose up -d

The images will be downloaded and the containers will be started.
If you are not the shell guy, I suggest you to install Kitematic, which is a GUI for docker. It will enable you also to change some parameters, but I prefer to do it in the above file docker-compose.yml I am using mostly to retrieve the virtual container IP and so to access the WordPress site (Example on the image below).

Docker WordPress IP address

For example: My WordPress site is now accessible on the URL address: (port 80)

Accessing Docker WordPress files

OK, now the Docker WordPress development environment is up and running. The next question is, how to access the Docker WordPress files. The easier way to managed it is through Kitematic.
Just click on the volume /var/www/html (visible on the image below), which will be instantly mounted and files will be displayed in the selected folder (which will also be automatically displayed).

docker wordpress volume

The described process above is covering everything you need to know About Docker for a simple Docker WordPress development. But if you want to dig dipper into doker, checkout my blog post Docker Cheat Sheet.


Follow deanpodgornik on

Comments (0)

Leave a Reply

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