BEST FREE WORDPRESS RESOURCES FOR ALL USERS

In this article, we’ll see how to install WordPress with docker. I’ll explain it in 2 simple steps.

So let’s straight jump into the tutorial. But first, let’s take a sneak peek at docker.

What is Docker?

Docker allows you to create, run, and test various applications on the same machine. In simple words, it is an open-source container platform that gives different environments for different applications but on the same machine.

Docker allows you to install the software simply and fastly on any system. Anyone can bundle a program and its dependencies into a standardized building block using this method.

Docker containers do not require their own operating system and host’s kernel. As a result, the demand on the machine is much lighter, and a single server can operate numerous containers at the same time.

As a result, Docker is extremely beneficial to WordPress developers. A WordPress test environment often consumes a significant amount of system resources, however, Docker allows them to create a minimal environment without wasting server space or memory.

How to Install WordPress with Docker?

Follow the steps to learn and successfully install WordPress with Docker.

1. Install Docker

You can install Docker on Windows, Linus, and Mac OS. Here’s how you can install it on these operating systems.

Docker Installation on Windows

You can install docker on any windows version, but for the sake of this tutorial, we’ll be using Windows 10 64 bit.

  1. Download Docker for windows from Docker Hub.
  2. Double click the Docker Desktop Installer.exe to run the installer.
  3. On the Configuration page, make sure Enable Hyper-V Windows Features or Install needed Windows components for WSL 2 is selected when requested.
  4. Now, click on the OK to install the docker.
docler install


5. Once the installation is finished, hit Close and you’ll see the Docker icon on the desktop.

Docker Installation on Mac OS

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:

docker app drag


2. To start Docker, double-click Docker.app in the Applications folder. During the configuration process, you’ll be asked to enter your password.

enter password for docker


3. When the installation is complete, the docker menu will appear in the status bar of your desktop.

Docker Installation on Linux

If you a re using Ubuntu 18.04 LTS follow the following steps to install docker

1. Update the Packge list:

sudo apt-get update

2. Allow apt to connect to a repository over HTTPS:

sudo apt-get install 
    apt-transport-https 
    ca-certificates 
    curl 
    gnupg-agent 
    software-properties-common

3. Add the Docker’s GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

4. Add the Docker’s repository:

sudo add-apt-repository 
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu 
   $(lsb_release -cs) 
   stable"

5. Update the Docker’s repository:

sudo apt-get update

6. Install Docker:

sudo apt install docker-ce

Other Linux distributions (such as CentOS, Debian, or Fedora) have different installation procedures. See Docker’s official docs if you don’t use Ubuntu.

2. Install WordPress with Docker

Let’s now install WordPress on Docker. The CLI and Docker compose are two techniques for accomplishing this task.

In this lesson, we’ll use Docker compose, which is a more organised and systematic approach. Here’s how to do it:

1. Check Docker Compose Installation:

docker-compose --version

2. Create a new directory for WordPress:

mkdir ~/wordpress/
cd ~/wordpress/

3. In the new directory, create a new docker-compose.yml and paste the below code. Remember to update your 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. To create the containers, run this command in the directory:

docker-compose up -d

5. The WordPress setup screen will appear after you type localhost:8000 into your browser.

docker wordpress installation screen 1024x711 1


Wrapping Up

You’ve learned how to install Docker on Linux, macOS, and Windows in this article. You’ve also learnt how to use the Docker Compose software to install WordPress on Docker.

You may want to read:

If this article really helped you to install WordPress with Docker then please join our family on TwitterFacebook, and Instagram. You can also join the YouTube Channel Community for WordPress video tutorials.

SHARE

Join The Family

Get fresh content from WPScholor

Popular Guides

Popular Deals