In this note, I wanna an automatical setting up of basic things.

👉 Install Docker by following this note.

WP basic without backup

Make a folder name mysite containing,

mysite
|-- docker-compose.yml  # main file
|-- backup              # contains backup files using AIO WP Migration plugins
|-- plugins             # contains plugins
|-- themes              # contains templates
|-- wordpress           # main site's sources

In the docker-compose.yml,

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:
        - './html/:/var/www/html/'
        - './plugins/:/var/www/html/wp-content/plugins/'
        - './themes/<theme>/:/var/www/html/wp-content/themes/<theme>'

  db:
    image: mysql:5.7
    restart: always
    environment:
        MYSQL_DATABASE: exampledb
        MYSQL_USER: exampleuser
        MYSQL_PASSWORD: examplepass
        MYSQL_RANDOM_ROOT_PASSWORD: '1'

Start the container,

cd mysite
docker-compose up -d
# check running containers
docker ps -a

Browse http://localhost:8080 to install wordpress by gui.

Debug

In the case you wanna see the list of users or access to the mysql environement,

# connect to MySQL running container
docker exec -it <container_db> bash

# connect to mysql database
mysql -u wordpress -p

# list all users
SELECT host, user FROM mysql.user;

Install WP-CLI

# Download wp-cli
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
# Make it executable
chmod +x wp-cli.phar
# Move it into /usr/local/bin/wp
sudo mv wp-cli.phar /usr/local/bin/wp
# Check whether the installation worked
wp --info

For example, activate all-in-one-wp-migration (already copied / placed in folder plugins)

wp plugin activate all-in-one-wp-migration --allow-root

Errors & warnings

apache2: Could not reliably determine the server's fully qualified domain name
# enter to wordpress container's bash
docker exec -it <container> bash
# add
echo 'ServerName localhost' >> /etc/apache2/apache2.conf
# restart apache/container
service apache2 restart
Could not create directory on mounted volume
# enter to wordpress container's bash
docker exec -it <container> bash
# then
chown -R www-data:www-data /var/www
Your file exceeds the maximum upload size for this site: 2 MB
# .htaccess
php_value upload_max_filesize 400M
php_value post_max_size 400M
# php_value memory_limit 256M
# php_value max_execution_time 300
# php_value max_input_time 300

References

Notes with this notation aren't good enough. They are being updated.