Take your WordPress development to the next level with docker

How to install WordPress locally on Mac simply with Docker Compose file

Common Practice

There is a common practice on how to setup WordPress development locally, most people use XAMPP and WAMP … but is there a better way, which saves you from doing all the XAMPP and WAMP configuration and unique urls? Why not use the power of containers to install a separate instance of WordPress for each development site? Create a site in 5 minutes!!

 

Quickest and Fastest Way to create WordPress on Docker

Today I would like you to show for me the easiest and fastest way how to make WordPress work for you on your local development machine in a few simple steps. We can use Docker hub and it will take less than 10 minutes.

Create a directory for your WordPress site and copy in the WordPress Docker Image File

1. Download and Install Docker

Download Mac stable installation on official Docker hub domain here:

Download Docker Desktop

2. Run installation from the dmg file you have downloaded.

3. Approve access and privileged access that Docker Desktop will ask for.

Adding WordPress to our docker install

Create a directory for your WordPress site and copy in the WordPress Docker Image File

4. Create a folder for the website for example: wpwebsite

Or Use the terminal to create folder:

mkdir wpwebsite

5. Enter into the directory

cd wpwebsite

6. Save the docker-compose.yml into wpwebsite directory.

It’s a file that contains all the docker ingredients needed to install all the items, like WordPress directory structure and mysql database as well.

docker-compose.yml

File contents:

version: '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:5.1.1-php7.3-apache

    ports:

      - "8000:80"

    restart: always

    environment:

      WORDPRESS_DB_HOST: db:3306

      WORDPRESS_DB_USER: wordpress

      WORDPRESS_DB_PASSWORD: wordpress

    working_dir: /var/www/html

    volumes:

      - ./wp-content:/var/www/html/wp-content

      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini

volumes:

  db_data:

Running WordPress Docker Container

Once the file is moved into the directory open a terminal and run the file

 

7.  Now type into terminal this simple command.

Docker-compose up

Next steps we Login into WordPress And Install

Open a web browser and go through a standard WordPress install

8. You are ready to go through WordPress installation on your local machine. Go into the browser and type this URL.

http://localhost:8000

Docker Desktop Dashboard

Pass all this installation and now you are ready to login to your local WordPress installation. You can check it as well on Docker Desktop Dashboard clicking on a tiny icon on your top panel.

And check it anytime how DB and website are running and stop or delete it anytime.

9. Login Into WordPress CMS

When you want to access your local WordPress installation next time just type wp-login.php after

localhost:8000, so whole URL to start installation will be like this:

http://localhost:8000/wp-login.php

Enjoy your Local WordPress Development

Leave a Reply

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