Deploying WordPress using Docker Compose
Next, I defined a Docker Compose file that would install WordPress for me. I got this file from the official WordPress Docker Hub page:
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- wordpress:/var/www/html
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql
volumes:
wordpress:
db:
Once I saved this file as docker-compose.yml, I executed docker-compose against it via the following command:
docker-compose up -d
After a few minutes, the command exited. To tell what the command did, I performed some verification steps. I looked at:
- what images the Compose file pulled down.
- What volumes were created
- what ports were exposed
xxx@wordpress:~$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
wordpress latest 0947f14b932b 2 weeks ago 540MB
mysql 5.7 c4f186b9e038 2 weeks ago 435MB
xxx@wordpress:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
55b0a9973f8f wordpress:latest "docker-entrypoint.s…" 21 hours ago Up 3 hours 0.0.0.0:8000->80/tcp dan_wordpress_1
b2e68230b7a7 mysql:5.7 "docker-entrypoint.s…" 21 hours ago Up 3 hours 3306/tcp, 33060/tcp dan_db_1
xxx@wordpress:~$$ docker volume ls
DRIVER VOLUME NAME
local 04576b665baedd049287321d8be8688ffaa583d4b77d6edf4a03678eb5dc5ab0
local xxx_db_data
xxx@wordpress:~$
Leave a Reply