Software Development

WordPress development with Docker Compose

Last post I told you about how to setup two dockers to run WordPress and MariaDB together. So, in this post I will show thow to use the docker-compose, that is a tool to help you setup run your dockers with one single command.


In cool distros you should be able to install docker-compose with command below.

sudo pacman -S docker-compose

In other distros, you should have the pip installed to have docker-compose. With pip, try the command below

sudo pip install docker-compose


The docker-compose utility rely on a file named docker-compose.yml. This file stores information about how to run one or more docker containers. You can quickly start, stop and remove a set of dockers with docker-compose.

For example, you can have a docker-compose.yml at root of your theme project and with a single command, start a set of dockers to start wordpress and mysql with your plugin already installed in plugins folder. Check the docker-compose.yml below.

  image: montefuscolo/wordpress
   - ./:/var/www/html/wp-content/plugins/mapasdevista
   - db:mysql
   - "80:80"
  image: mariadb
   - MYSQL_USER=thewpuser
   - MYSQL_PASSWORD=thewppass
   - MYSQL_DATABASE=wordpress
   - MYSQL_ROOT_PASSWORD=thesuperpass
  1. web: and db: There are 2 dockers declared, one named web and other named db
  2. image: A custom WordPress image[1] is used for web container
  3. volumes: The local folder is flagged to be mounted inside plugins folder of web container
  4. environment: a variable is declared to turn on debug in WordPress
  5. links: db is linked with web, but inside web container the db is called mysql
  6. ports: the port 80 is exposed and published from web to host
  7. In db container, the official maridb image is used

With this file placed at your theme folder, anyone with docker-compose can quickly setup a environment for test and develop the plugin.


All commands should be run at same folder of docker-compose.yml.

To create and run containers try the command below and point your browser to http://localhost.

$ docker-compose up

To stop containers you can type Ctrl+C at terminal running docker-compose or in another terminal in same folder, you can use the command below.

$ docker-compose stop

To start your already created containers, the command is:

$ docker-compose start

To stop and destroy your containers:

$ docker-compose down


Using docker-compose you can run and develop your WordPress stuff right after clone. You don’t need to worry about setup a webserver, database, setup permissions. With docker you can get all running quickly.