Change the Docker source

Improved image download speed of Docker. Use vim to edit /etc/docker-daemon. json and add the following content.

{
  "registry-mirrors": ["https://n6ktfef7.mirror.aliyuncs.com"]
}
Copy the code

Pull the MySQL image and run the MySQL container

Docker pull mysql: 5.6 docker run - d - ring = true - name wpMysql - v/data/mysql: / var/lib/mysql - e MYSQL_ROOT_PASSWORD = 123456 - p, 3307:3306 mysql: 5.6Copy the code
  • -p: indicates port mapping. 3307 of the host is mapped to 3306 of the mirror
  • -e: environment variable 123456 when setting the root password of the MySQL database in the mirror
  • -v: specifies the data volume to be added to the MySQL container/var/lib/mysqlMapped to the host/data/mysql
  • — Privileged =true: Security Selinux in CentOS prevents some security privileges. As a result, the MySQL container will report an error when running because of insufficient privileges, so you need to add this option

Pull the WordPress image and run the WordPress container

docker pull wordpress:latest
docker run -d --name mwp -v /data/wordpress/www/html/:/var/www/html/ -e WORDPRESS_DB_HOST=mysql -e WORDPRESS_DB_PASSWORD=123456 -p 2020:80 --link wpMysql:mysql wordpress
Copy the code
  • -v: specifies the data volume to be added to the WordPress container/var/www/html/Mapped to the host/data/wordpress/www/html/
  • “WORDPRESS_DB_HOST”: IP address and port of the linked docker MySQL, usually set to MySQL representation using default Settings
  • “WORDPRESS_DB_USER”: what user is used to use MySQL, root by default
  • “WORDPRESS_DB_PASSWORD” sets the password for logging in to MySQL. This is the same as “MYSQL_ROOT_PASSWORD “because the previous entry is the default root.
  • “WORDPRESS_DB_NAME”: indicates the name of the database table. You do not need to change it. Use the default “wordpress”
  • –link: Connect to other containers
  • -d: background running

The installation is complete

If you log in using HTTPS + domain name, you will find that js and CSS cannot be loaded after entering the address. The solution is as follows:

/data/ WordPress/WWW/HTML, modify the configuration vi wp-config.php

$_SERVER['HTTPS'] = 'on';
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);
Copy the code

Reference data: www.jianshu.com/p/2faca4e1f…