Photo material from

Instant Docker local environment for Wordpress

Whether you are a web developer or running business based on mass production of websites, you or your employees must be using local environment for faster development. In the past, fastest way for the local environment was to set up server stack MAMP/LAMP/etc. or image on some virtual machine like VirtualBox.

Then a few years ago new, simple and powerful player emerged. He is called Docker. For those who are not familiar with it — Docker is a virtual machine which uses containers for virtualisation. In most cases, it works out-of-the-box. You can read more about it on their official website, where you can find extensive guides for easy understanding and simple configuration.

Currently running containers for Wordpress local website environment

Now with Docker, the local development is even easier and faster. You can have fully functional Wordpress website up and run under a minute. You only need to create a file with docker configuration, which can then be copied and used for future projects Wordpress local environments.

So after you get to know Docker and have installed all needed tools for working with it, you are ready for next — more interesting step. you can also download complete project on Github.

How to configure Docker environment

For setting up Docker, we will use Compose tool.

“Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a Compose file to configure your application’s services. Then, using a single command, you create and start all the services from your configuration.”
— from

First, we create a folder called docker-instant-wp which will be used as the folder for our new project. Inside we create file docker-compose.yml

This file is used for local environment configuration of Docker containers. We will specify which image should Docker use for specific container and also configure the connection between Wordpress and database easily as possible. We will set-up volumes for persistent data, so the changes in files will be visible on the host computer as in the container.

Our environment will have 3 containers (WordPress, database, PHPMyAdmin). This is all of the containers we would need to easily deploy the finished website to the production server. The changes in files are visible in our hosts’ folder and we can easily dump database with phpMyAdmin and import it on the production site.


image: wordpress
- mariadb:mysql
- "8000:80"
- ./wordpress:/var/www/html
image: mariadb
- MYSQL_DATABASE=wordpress
- ./database:/var/lib/mysql
image: phpmyadmin/phpmyadmin
- mariadb:mysql
- "8181:80"
- PMA_HOST=mysql

This configuration file can be used for future projects without any modifications. You can just stop the running containers from one website and run another one. For running multiple containers at same time, only few modifications to ports would be necessary.

Let us start Docker local environment

We can easily start the environment if we open up Terminal or any other command-line tools then navigate to project folder and run command docker-compose up (you must previously install docker-compose module so you can use it in terminal).

Usage of docker-compose command for starting local Wordpress environment

After you run the command, you can see the progress of building our local environment printing on the screen. If you don’t have images locally, the Docker will download it for you. When Docker starts building your environment, hosts folder docker-instant-wp will get populated with Wordpress and database files.

If everything runs smoothly, your website will be available at localhost on port 8000 and terminal will be used for printing server requests you make on your local website. Your database access with phpMyAdmin will be on port 8181.

Quickly add desired plugins with Composer and Packagist

We can create JSON file for all the dependencies we need in our Wordpress website. Usually that would be plugins, theme, fonts, etc. For basic setup is more then enough if we only install few plugins (which we install on every single website). Plugins can be added to Composer file through When you have composer configuration JSON file, you can go to root path in the terminal and install needed dependancies with “composer.phar install”. Composer will install needed plugins in folder we specified in configuration.

"require": {
"extra": {
"installer-paths": {
"wordpress/wp-content/plugins/{$name}/": ["type:wordpress-plugin"]


These days, when everything is moving fast — you got to keep up with the flow. If you can not keep it up, you are going to sink. It is that simple. So for business with mass production of websites, I would advise this: give Docker a chance. It sure deserves it.

“ This reduces the risk of — worked in dev, now an ops problem. ” ― James
Turnbull, The Docker Book: Containerization is the new virtualization

If you enjoyed reading this article, show some ❤ and be the reason for even more daily motivation. I sure am doing the same thing. Enjoy your day and thank you for stopping by.

Please reach out if you have any questions or proposal! You can follow me and ask questions on Twitter or contact me via email.