How to Install WordPress on Docker (Windows, macOS, Linux)

How to Install WordPress on Docker (Windows, macOS and Linux)

If you are looking for a way to create isolated environments to test your WordPress, then familiarize yourself with container technology. In this article, we’ll cover a step-by-step guide to install WordPress on Docker, the best-known container platform.

Download Complete Linux Commands Cheat Sheet

What Exactly Is Docker?

Docker is an open-source containerization software that creates isolated environments to run an application. Hence, you develop, test, and run multiple applications on the same machine.

In contrast to virtual machines, each container does not require its own OS and shares the host’s kernel. Thus, the machine’s workload is far more lightweight and a single server can run multiple containers at the same time.

For that reason, Docker is highly useful for WordPress developers. A WordPress test environment usually eats up a lot of system resources, but Docker helps them make a minimal environment without wasting server space and memory.

How to Install WordPress on Docker?

Follow the steps below and learn how to install WordPress on Docker.

Step 1: Installing Docker

Docker is available for Windows, macOS, and Linux. Here’s how you can install it on those three operating systems:

Linux Installation

If you’re using Ubuntu 18.04 LTS, follow these steps:

  1. Update the package list:
    sudo apt-get update
  2. Let apt access a repository over HTTPS:
    sudo apt-get install 
  3. Add the Docker’s GPG key:
    curl -fsSL | sudo apt-key add -
  4. Add the Docker’s repository:
    sudo add-apt-repository 
       "deb [arch=amd64] 
       $(lsb_release -cs) 
  5. Update the Docker’s repository:
    sudo apt-get update
  6. Install Docker:
    sudo apt install docker-ce

Keep in mind that other Linux distributions (CentOS, Debian, or Fedora) have different installations steps. If you don’t use Ubuntu, see Docker’s official documentation.

macOS X Installation

Here are the procedures to install Docker on macOS:

  1. Download Docker for Mac and double-click the .dmg file you’ve saved. Then, drag and drop the Docker icon to your Applications folder. You can find download links here:
  2. Open your Applications folder and double-click During the configuration process, you’ll be asked to enter your password.
    Enter Password for Docker on macOS
  3. Once the installation process is finished, you’ll see the docker menu in your desktop’s status bar.

Windows Installation

Here’s how you can install Docker on Windows 10 64-bit:

  1. Enable Hyper-V in your system.
  2. Download Docker Desktop for Windows and open the Docker for Windows Installer file.
  3. In the Configuration dialog window, check or uncheck the boxes based on your preferences. Click Ok.This image shows you the configuration options when installing Docker on Windows
  4. Once the installation is finished, hit Close. You’ll see the Docker icon in the taskbar.

Step 2:  Setting-Up WordPress on Docker

Next, let’s set up WordPress on Docker. You can do this process with these two methods ‒ the CLI and Docker compose.

In this article, we’ll be using Docker compose, the cleaner and more systematic method. Here’s how:

  1. Check Docker Compose Installation: docker-compose --version
  2. Create a new directory for WordPress: mkdir ~/wordpress/ cd ~/wordpress/
  3. Create a new docker-compose.yml in the new directory and paste the content below. Don’t forget to change the credentials. version: '3.3' services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DB_NAME: wordpress volumes: db_data:
  4. Run this command in the directory to create the containers: docker-compose up -d
  5. Your browser will enter localhost:8000 and display the WordPress setup screen.Docker WordPress Installation Screen


Docker is a great containerization tool to experiment with WordPress. Its minimal environment helps you maintain the efficiency of your system resources.

In this tutorial, you’ve learned how to install Docker on Linux, macOS, and Windows. You’ve also learned how to set up WordPress on Docker using the Docker Compose utility.

We hope this simple tutorial is helpful. If have any further questions, share with us in the comments section below.


Domantas leads the content and SEO teams forward with fresh ideas and out of the box approaches. Armed with extensive SEO and marketing knowledge, he aims to spread the word of Hostinger to every corner of the world. During his free time, Domantas likes to hone his web development skills and travel to exotic places.

Source link

We will be happy to hear your thoughts

Leave a reply

Best & Lowest Rates of all online shopping Products
Compare items
  • Total (0)
Shopping cart