Skip to content

Instantly share code, notes, and snippets.

@ibrahim-kardi
Created November 1, 2023 17:24
Show Gist options
  • Save ibrahim-kardi/9bfe940ecefb49c9d7cd86c458095c67 to your computer and use it in GitHub Desktop.
Save ibrahim-kardi/9bfe940ecefb49c9d7cd86c458095c67 to your computer and use it in GitHub Desktop.
Docker with WordPress
# YAML is a human-readable data-serialization language. It is commonly used for configuration files and in applications where data is being stored or transmitted.
version: '3.1' # Compose file versions
services:
#Database
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always #Database will restart with container
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- wpNetwork #it can be any name
#php
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
environment:
PMA_HOST : db
MYSQL_ROOT_PASSWORD: password # Same as Database
networks:
- wpNetwork
#WordPress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8080:80"
restart: always
volumes: ["./:/var/www/html"]
environment:
WORDPRESS_DB_HOST: db:3306 # WordPress Default Port
WORDPRESS_DB_USER: wordpress # Same as Database
WORDPRESS_DB_PASSWORD: wordpres # Same as Database
networks:
- wpNetwork
networks:
wpNetwork:
volumes:
db_data:
# Tarminal code
docker-compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment