Docker containers are like magic. You can create a wodpress instance in minutes.
Today i create a docker-compose.yml file for a WordPress inance.
Just create the file with the commands bellow and you will get a WordPress site. You will not loose the customizations because they are saved on the host machine.
Create the folders /wp-content and wp-content/uploads bellow the folder that contains docker-compose.yml. I test this instance only on my Mac for development.
version: ‘3’
services:
db:
image: mysql:5.7
volumes:
– db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: password
wordpress:
depends_on:
– db
image: wordpress:latest
volumes:
– ./wp-content/uploads:/var/www/html/wp-content/uploads
– ./wp-content:/var/www/html/wp-content
ports:
– “8000:80”
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: password
volumes:
db_data: