docker compose 链接
https://www.cnblogs.com/zhijiyiyu/p/15417805.html
https://www.cnblogs.com/hopeblaze/articles/18646249
https://blog.csdn.net/m0_37643701/article/details/144957553





curl -L https://github.com/docker/compose/releases/download/v2.0.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
cd /usr/local/bin/
ls
chmod  +x docker-compose
ll docker-compose
cd
docker-compose  -v

nginx配置文件修改
server_name 若访问IP地址方式那么修改为宿主机IP地址或者nginx容器IP地址均可  若域名访问直接填写域名
WordPress  /wordpress/wp-config.php修改
/** WordPress数据库的名称 */
define('DB_NAME', '');
/** MySQL数据库用户名 */
define('DB_USER', '');
/** MySQL数据库密码 */
define('DB_PASSWORD', '');
/** MySQL主机 */
define('DB_HOST', '');
#使用版本2(3版本不支持指令volumes_from)
version: '2'
networks:
  lnmp-network:
    driver: bridge
    ipam:
      config:
        - subnet: 172.18.0.0/24
          gateway: 172.18.0.1
services:
  #配置nginx服务
  nginx:
    #加入到lnmp网络中指定IP地址
    networks:
      lnmp-network:
        ipv4_address: 172.18.0.2
    #设置主机名为nginx
    hostname: nginx
    #指定镜像
    image: c8d03f6b8b91
    #容器名为nginx
    container_name: nginx
    #暴露端口80和443
    ports:
      - 80:80
      - 443:443
    #将目录挂载到容器内
    volumes:
      - /nginx:/etc/nginx
      - /wordpress:/wordpress
      - /var/log/nginx/access.log:/var/log/nginx/access.log
      - /var/log/nginx/error.log:/var/log/nginx/error.log
    #指定容器时区
    environment:
      - TZ=Asia/Shanghai
    #设置超级用户权限：
    privileged: true
    #设置容器重启策略nginx服务随nginx容器启动而启动
    restart: always
  #配置服务mysql
  mysql:
    networks:
      lnmp-network:
        ipv4_address: 172.18.0.3
    hostname: mysql
    image: 5107333e08a8
    container_name: mysql
    ports:
      - 3306:3306
    volumes:
      - /mysql:/var/lib/mysql
      - /my.cnf:/etc/my.cnf 
      - /var/log/mysql/mysqld.log:/var/log/mysqld.log 
      - /etc/localtime:/etc/localtime:ro
    #指定容器时区
    environment:
      - TZ=Asia/Shanghai
    #设置超级用户权限
    privileged: true
    #设置容器重启策略
    restart: always
  #配置服务php    
  php:
    networks:
      lnmp-network:
        ipv4_address: 172.18.0.4
    hostname: php
    image: 38f2b691dcb8
    container_name: php
    ports:
      - 9000:9000
    volumes:
      - /php.ini:/usr/local/etc/php/php.ini
      - /wordpress:/wordpress 
    #php容器需要在nginx和mysql之后启动  
    depends_on:
      - nginx
      - mysql
    #php和容器nginx，容器mysql连接   
    links:
      - nginx
      - mysql
    #指定容器时区
    environment:
      - TZ=Asia/Shanghai
    #设置超级用户权限
    privileged: true
    #设置容器重启策略
    restart: always
#在工作目录使用此命令。
#-f： --file-name, 指定模板文件。默认为docker-compose.yml
#-p: --project-name NAME ，指定项目名称，默认使用目录名
#-d： 在后台运行
