WordPress is one of the world’s most popular content management systems (CMS). Millions of users use it to build websites of different sizes, from personal blogs to enormous business websites.
If you’re new to WordPress, you might be wondering how to get it up and running. There are several methods for installing WordPress, but one of the simplest is to utilize Docker.
Docker is a containerization technology that simplifies the packaging and deployment of programs. WordPress can be installed with only a few commands using Docker.
We’ll teach you how to install WordPress on Docker for Windows, macOS, and Linux in this article.
Table of Contents
What Exactly Is Docker
Docker is an open-source containerization platform that provides separate environments in which to execute different applications. Multiple applications can be developed, tested, and operated on the same physical and virtual servers.
Unlike virtual machines, containers do not require their own operating system because they share the host kernel. As a result, the machine’s workload is substantially lighter, and such a server may run numerous containers concurrently without compromising performance.
Docker, for example, is extremely handy for WordPress developers. A WordPress test environment often consumes a significant amount of system resources; however, Docker enables developers to create a minimum environment without wasting server space or memory.
How to Deploy WordPress Image as a Docker Container
The methods below will walk you through installing a WordPress content management system on a Docker container.
Install Docker
Docker runs on Windows, macOS, and Ubuntu. Installing it on any of the three operating systems is as follows:
Initial Setup
To install Docker on a Linux VPS, you must first have a virtual private server (VPS) running one of the following operating systems:
- Ubuntu Jammy 22.04 (LTS)
- Ubuntu Impish 21.10
- Ubuntu Focal 20.04 (LTS)
- Ubuntu Bionic 18.04 (LTS)
Start by updating the packages to the latest version available.
Update the package list:
sudo apt update
sudo apt upgrade
Read this article to install Docker.
How to Install Docker on Ubuntu
Install and Use Docker Compose with Docker on Ubuntu
How to Install Docker on macOS
To install Docker on a macOS computer, the following requirements must be met:
- 4 GB of RAM
- macOS version 10.15 or newer
- No previous versions of VirtualBox 4.3.30 can be installed.
Here’s how you can install Docker on macOS:
- Download Docker for Mac and double-click the .dmg file you’ve saved. Then, drag and drop the Docker icon into your Applications folder.
You can find download links here:
2.Navigate to the Applications folder and double-click docker.app. You will be prompted to enter your password throughout the setting procedure.
3. Accept the service agreement when offered; otherwise, the installation will fail.
4. When the installation is complete, the Docker menu should appear in the status bar of your desktop.
How to Install Docker on Windows
To install Docker Desktop on a Windows system, the following requirements must be met:
- 4 GB of RAM
- 64-bit processor from 2010 or more recent
- Virtualization enabled in BIOS
- Linux kernel update package installed if you are using the WSL 2 Docker back-end.
Here’s how you can install Docker on Windows 10 64-bit:
- Enable Hyper-V on your system.
- Download Docker Desktop for Windows and open the Docker for Windows Installer file.
- In the Configuration dialog window, check the boxes based on your preferences. Click Ok.

4.When the installation is complete, click Close and restart and wait for your computer to restart.
5. Accept the service agreement after rebooting, and Docker will be ready to use.
Step 2 – Set Up WordPress Container on Docker
There are two ways to install WordPress on Docker: the CLI via Docker compose. We’ll utilize the Docker compose approach in this tutorial because it’s more basic and methodical.
It’s worth noting that all required images are acquired from Docker Hub:
- WordPress – the official WordPress Docker image. Includes all WordPress files, Apache server, and PHP.
- MySQL – required for MySQL root user, password, and database connection variables.
- phpMyAdmin – a web application for managing databases.
WordPress is the official Docker image for WordPress. All WordPress files, the Apache server, and PHP are included.
MySQL – MySQL root user, password, and database connection variables are all necessary.
phpMyAdmin is a database management online application.
- With the following command, create a new project directory for the WordPress application:
mkdir wordpress
2. Navigate to the new directory:
cd wordpress
In your favorite text editor, create a new docker-compose.yml file and paste the contents below:
version: "3"
# Defines which compose version to use
services:
# Services line define which Docker images to run. In this case, it will be MySQL server and WordPress image.
db:
image: mysql:5.7
# image: mysql:5.7 indicates the MySQL database container image from Docker Hub used in this installation.
restart: always
environment:
MYSQL_ROOT_PASSWORD: MyR00tMySQLPa$$5w0rD
MYSQL_DATABASE: MyWordPressDatabaseName
MYSQL_USER: MyWordPressUser
MYSQL_PASSWORD: Pa$$5w0rD
# Previous four lines define the main variables needed for the MySQL container to work: database, database username, database user password, and the MySQL root password.
wordpress:
depends_on:
- db
image: wordpress:latest
restart: always
# Restart line controls the restart mode, meaning if the container stops running for any reason, it will restart the process immediately.
ports:
- "8000:80"
# The previous line defines the port that the WordPress container will use. After successful installation, the full path will look like this: http://localhost:8000
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: MyWordPressUser
WORDPRESS_DB_PASSWORD: Pa$$5w0rD
WORDPRESS_DB_NAME: MyWordPressDatabaseName
# Similar to MySQL image variables, the last four lines define the main variables needed for the WordPress container to work properly with the MySQL container.
volumes:
["./:/var/www/html"]
volumes:
mysql: {}
After you’ve created the Docker Compose file, execute the following command in the same WordPress directory to create and start the containers:
docker compose up -d
Step 3 – Complete WordPress Installation on a Web Browser
Enter your browser’s address.
http://localhost:8000/. The WordPress installation screen will display. Continue by selecting your favorite language.

Enter your site’s name, username, password, and email address.
When a Success! message appears, log in with your newly created credentials.
Finally, you’ll be sent to the main WordPress dashboard screen.
Setting up phpMyAdmin
phpMyAdmin is an excellent program for examining and managing existing databases. Simply add the following lines to an existing .yml file, directly after the services line, along with the MySQL database service:
version: "3"
services:
db:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: MyR00tMySQLPa$$5w0rD
MYSQL_DATABASE: MyWordPressDatabaseName
MYSQL_USER: MyWordPressUser
MYSQL_PASSWORD: Pa$$5w0rD
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
restart: always
environment:
PMA_HOST: db
PMA_USER: MyWordPressUser
PMA_PASSWORD: Pa$$5w0rD
ports:
- "8080:80"
Save the file and run the docker-compose Docker command:
docker compose up -d
Once done, open http://localhost:8080/, and you’ll be able to see the phpMyAdmin interface along with your WordPress database.
Website Development on WordPress Docker Container
Docker is also an amazing development tool. It enables developers to utilize Docker Compose to easily use WordPress instances in a Docker-based isolated environment.
Assume a developer want to test a plugin or theme on a certain WordPress version. In that situation, they can simply change the main YAML file to add the WordPress version they require and test everything from there.
Finding and manipulating files is also quite simple. When a user uses Docker to download an official WordPress image, it builds all of the essential files and directories, such as wp-content, wp-admin, and wp-includes. As a result, the entire development environment behaves just like a real WordPress website.
Docker also makes it straightforward and convenient to share development builds with your team, since all you need to do is setup your own registry. The entire team will then be able to exchange images by using the docker pull and docker push commands.
This article is to help you learn how to install WordPress on Docker. We trust that it has been helpful to you. Please feel free to share your thoughts and feedback in the comment section below.