WordPress & Docker

Sebastian Eschweiler
May 16 · 7 min read

WordPress Containerization With Docker



Setting Up A docker-compose.yml file

version: '3'services:
db:
image: mysql:8
container_name: mysql
restart: always
command: "--default-authentication-plugin=mysql_native_password"
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wpdb
MYSQL_USER: user
MYSQL_PASSWORD: password
command: "--default-authentication-plugin=mysql_native_password"

Adding The WordPress Service

services:
[...]
wordpress:
image: wordpress:4.9.8
container_name: wordpress
restart: always
volumes:
- ./wp-content:/var/www/html/wp-content
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: wpdb
WORDPRESS_DB_USER: user
WORDPRESS_DB_PASSWORD: password
ports:
- 8080:80
- 443:443

Adding The phpMyAdmin Service

services:
[...]
phpmyadmin:
image: phpmyadmin/phpmyadmin
restart: always
ports:
- 3333:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORT: password

The Complete docker-compose.yml File:

version: '3'services:
wordpress:
image: wordpress:4.9.8
container_name: wordpress
restart: always
volumes:
- ./wp-content:/var/www/html/wp-content
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: wpdb
WORDPRESS_DB_USER: user
WORDPRESS_DB_PASSWORD: password
ports:
- 8080:80
- 443:443
db:
image: mysql:8
container_name: mysql
restart: always
command: "--default-authentication-plugin=mysql_native_password"
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wpdb
MYSQL_USER: user
MYSQL_PASSWORD: password
phpmyadmin:
image: phpmyadmin/phpmyadmin
restart: always
ports:
- 3333:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORT: password

Starting All Services

Conclusion

Top 3 Docker Online Courses

CodingTheSmartWay.com Blog

CodingTheSmartWay.com is a blog about latest web and mobile technologies.

Sebastian Eschweiler

Written by

Full-stack Web Developer, CodingTheSmartWay.com

CodingTheSmartWay.com Blog

CodingTheSmartWay.com is a blog about latest web and mobile technologies.