Create a

docker-compose.yml

file in a any folder

i.e.

/Documents/Docker/mydomainsample.com/docker-compose.yml
docker-compose.yml
version: '2'

services:
 wordpress:
 depends_on:
 - mysql
 image: wordpress:php7.0
 ports:
 - "8080:80"
 volumes:
 - ./htdocs/assets:/var/www/html/wp-content
 links:
 - mysql
 environment:
 WORDPRESS_DB_HOST: mysql:3306
 WORDPRESS_DB_PASSWORD: wp

 mysql:
 image: mariadb:10.1.19
 ports:
 - "8081:3306"
 volumes:
 - ./databases:/var/lib/mysql
 environment:
 MYSQL_ROOT_PASSWORD: wp

Know Issues

WordPress Docker not starting or closing unexpectedly:

This happen because the MySQL docker database doesn’t have the necessary permissions:

Step 1: Access the docker cluster:

docker exec -it my_wordpress_mysql_docker_cluster bash

Step 2: Access MySQL:

msyql -uroot -pwp

Step 3: Allow MySQL WordPress User to access the databases:

GRANT ALL ON *.* to yourUser@'%' IDENTIFIED BY 'wp';