Did you know?

Ambangeg trail in Mt. Pulag (3rd Highest Mountain in the Philippines) is also known as the “celebrity trail” because of its well established route. Vehicles can negotiate the trail all the way to the Ranger Station which is the entire Ambangeg Trail. - http://www.pinoymountaineer.com/2007/09/mt-pulag-2922.html

Prerequisites

Set up WordPress in Docker

  • In your folder, create the docker-compose.yml file.
  • Below is my docker-compose.yml file.
version: '3.9'

services:
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    ports:
      - 3307:3306
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    volumes:
      - wordpress_data:/var/www/html
    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: {}
  wordpress_data: {}

version of compose

version: '3.9'

DB Services

I'm using mysql:5.7 image, and attached mysql data to persist database. I'm using 3307 port because my 3306 is not available. And the environment section contains the variables of my login information for the database.

db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    ports:
      - 3307:3306
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    

Wordpress Services

This image depends on the database. I used port 8000.

wordpress:
    depends_on:
      - db
    image: wordpress:latest
    volumes:
      - wordpress_data:/var/www/html
    ports:
      - "8000:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress

The last element is the volumes section:

volumes:
  db_data: {}
  wordpress_data: {}

Execute

docker compose up

or

docker-compose up -d

This will take for a while.

If you then look at Docker Desktop app, you should see something like this:

Once done, execute

docker ps

Now let's open a browser and navigate to ‌http://localhost:8000/.

Just choose your desired language and the rest are just self explanatory.

Login using the credentials you set up.

Maybe you want to click the customize link on the upper left and do some changes.

Connecting to the database

I'm using HeidiSQL. - https://www.heidisql.com/

To stop docker, just execute:

docker-compose stop