1. Dockerネットワークを作成
$ sudo docker network create wordpressnet
$ sudo docker network ls
2. ボリュームの作成
$ sudo docker volume create wordpress_db_volume
$ sudo docker volume ls
3. mysqlコンテナを起動
$ sudo docker run –name wordpress-db -dit -v wordpress_db_volume:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=myrootpassword -e MYSQL_DATABASE=wordpressdb -e MYSQL_USER=wordpressuser -e MYSQL_PASSWORD=wordpresspass –net wordpressnet mysql:5.7
4. WordPressコンテナを起動
$ sudo docker run –name wordpress-app -dit -p 8080:80 -e WORDPRESS_DB_HOST=wordpress-db -e WORDPRESS_DB_NAME=wordpressdb -e WORDPRESS_DB_USER=wordpressuser -e WORDPRESS_DB_PASSWORD=wordpresspass –net wordpressnet wordpress
$ sudo docker stop wordpress-db wordpress-app
$ sudo docker rm wordpress-db wordpress-app
$ sudo docker network rm wordpressnet
$ sudo docker volume rm wordpress_db_volume
うん、割と簡単