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
db: There are 2 dockers declared, one named web and other named db
image: A custom WordPress image is used for web container
volumes: The local folder is flagged to be mounted inside plugins folder of web container
environment: a variable is declared to turn on debug in WordPress
links: db is linked with web, but inside web container the db is called mysql
ports: the port 80 is exposed and published from web to host
- 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
To create and run containers try the command below and point your browser to http://localhost.
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.
To start your already created containers, the command is:
To stop and destroy your containers:
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.