docker compose一键部署wordpress实战

                                              作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.编写docker-compose文件

version: '3.8'

services:
  db:
    image: mysql:8.0.36-oracle
    container_name: db
    restart: unless-stopped
    environment:
      - MYSQL_DATABASE=wordpress
      - MYSQL_ALLOW_EMPTY_PASSWORD=yes
      - MYSQL_USER=admin
      - MYSQL_PASSWORD=yinzhengjie
    # 定义存储卷
    volumes:
      - dbdata:/var/lib/mysql
    networks:
      - wordpress-network

  wordpress:
    depends_on:
      - db
    image: wordpress
    container_name: wordpress
    restart: unless-stopped
    ports:
      - "80:80"
    environment:
      - WORDPRESS_DB_HOST=db:3306
      - WORDPRESS_DB_USER=admin
      - WORDPRESS_DB_PASSWORD=yinzhengjie
      - WORDPRESS_DB_NAME=wordpress
    volumes:
      - wordpress:/var/www/html
    networks:
      - wordpress-network

# 定义存储卷
volumes:
  wordpress:
  dbdata:

networks:
  wordpress-network:
    driver: bridge
    ipam:
      config:
        - subnet: 172.30.100.0/24
 

二.启动实例

docker-compose up -d
posted @ 2024-10-26 00:40  尹正杰  阅读(32)  评论(0编辑  收藏  举报