分享下我博客的Docker Compose文件

文件主体

services:

# wordpress主体
  wordpress:
    image: wordpress
    container_name: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db #(不可随意更改,需与下方数据库部分一致)
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress_password
      WORDPRESS_DB_NAME: wordpress
    volumes:
      - ./wordpress:/var/www/html
      # depends部分决定启动顺序
    depends_on:
      - db
      - redis
    networks:
      - wordpress
# mysql数据库
  db:
    image: mysql:8.0    #(建议8.0,不建议5.7,不要随便更换,更不可跨大版本升级,且升级前一定要备份)
    container_name: wordpress_db
    restart: always
    command: --max-binlog-size=200M --expire-logs-days=2
    environment:
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: user_password
      MYSQL_ROOT_PASSWORD: root_password
    volumes:
      - ./db:/var/lib/mysql
    networks:
      - wordpress
# redis缓存
  redis:
    container_name: wordpress_redis
    image: redis:alpine
    restart: always
    environment:
      TZ: Asia/Shanghai
    volumes:
      - ./redis:/data
    networks:
      - wordpress
# 流量统计umami(需要去db容器中手动创建数据库)
  umami:
    image: ghcr.io/umami-software/umami:mysql-latest
    container_name: umami
    ports:
      - 3000:3000
    environment:
      DATABASE_URL: mysql://umami:mysql_password@db:3306/umami
      DATABASE_TYPE: mysql
      APP_SECRET: ramdom_string
    depends_on:
      - db
    restart: always
    networks:
      - wordpress

# 创建专用网络
networks:
  wordpress:
    name: wordpress

其他

  • 有其他问题可以在评论中留言哦,看到会回的!
© 版权声明
THE END
喜欢就支持一下吧
点赞1 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容