Code journal: Docker Compose+MariaDB+Wordpress+PHPMyAdmin

Checklist

Marcel Soliman
3 min readAug 25, 2023
[ ] Create folder structure
[ ] Create the /docker-compose.yml
[ ] Run containers
[ ] Check if containers are running
[ ] Test

Create folder structure

YourProjectFolder
└── docker-compose.yml

Create the /docker-compose.yml

# Docker Compose version
# https://docs.docker.com/compose/compose-file/compose-file-v3/
version: '3'

# Start of services
services:

# Define the 'wordpress' service.
wordpress:
# Use the official WordPress Docker image.
image: wordpress
# Expose port 8080 for communication within the network.
expose:
- 8080
ports:
# Map host port 8080 to container port 80 for external access.
- 8080:80
networks:
# Connect to the 'internal' network for communication.
- internal
# Set environment variables for the WordPress service.
environment:
# Set the db host
WORDPRESS_DB_HOST: mariadb
# Set the db name
WORDPRESS_DB_NAME: wp_db_001
# Set db user and password
WORDPRESS_DB_USER: wp_db_user
WORDPRESS_DB_PASSWORD: abcABC123!@# # change this!
volumes:
# Mount a local directory as a volume in the container.
- ./wordpress:/var/www/html

# Define the MariaDB service.
mariadb:
# Use the official MariaDB Docker image.
image: mariadb
expose:
# Expose port 3306 for communication within the network…

--

--

Marcel Soliman

I code for fun and share my code journals on Medium to pay for my coffee.