Installing WordPress and MySQL in Docker

This short guide is aimed at developers who want to quickly set up a WordPress development environment using Docker. It assumes you have Docker installed on your machine. If you don’t, you can download it from the official website.

The steps we will need to follow are just three:

  1. Creating required Docker Compose files
  2. Running the Docker Compose command
  3. Setting up WordPress

Creating required Docker Compose files

This Gist is a template for the docker-compose.yml file. It contains the WordPress and MySQL services, and also phpMyAdmin for database management. You can copy and paste it into a new file named docker-compose.yml.

Running the Docker Compose command

With a terminal open in the same directory as the docker-compose.yml file, run the following command:

docker-compose up -d

This command will download the required images and start the containers. The -d flag is used to run the containers in the background.

Setting up WordPress

Now that the containers are running, you can access WordPress by visiting http://localhost:8000 in your browser. You will be prompted to set up the site. The database connection details are passed through environment variables, so you don’t need to worry about them.

P.S.: A huge thank goes to Brad Traversy who setted up the composer script that I updated in this guide.

Posted in


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