部署docker compose环境

centos8.2安装docker compose

拉取镜像

docker pull nmtan/chevereto
docker pull mariadb

创建相关目录

mkdir -p /home/docker/chevereto/images && mkdir -p /home/docker/chevereto/conf
# 创建php.ini
cd /home/docker/chevereto/conf
vim php.ini

复制粘贴以下内容

memory_limit = 256M; # 运行内存
upload_max_filesize = 50M; # 最大上传文件大小
post_max_size = 50M; # 最大上传文件大小

创建容器编排文件

cd /home/docker/chevereto
vim docker-compose.yml

复制粘贴以下内容

version: '3'

services:
  db:
    image: mariadb
    container_name: mariadb
    # 挂载容器中的mysql数据卷到本地/home/docker/mariadb/data文件夹
    volumes:
      - /home/docker/mariadb/data:/var/lib/mysql:rw
    restart: always
    networks:
      - chevereto-net
    # 设置容器中的mysql的root用户密码以及其他用户
    environment:
      MYSQL_ROOT_PASSWORD: default123
      MYSQL_DATABASE: chevereto
      MYSQL_USER: chevereto
      MYSQL_PASSWORD: chevereto
    ports:
     - 9001:3306

  chevereto:
    depends_on:
      - db
    image: nmtan/chevereto
    container_name: chevereto
    restart: always
    networks:
      - chevereto-net
    # 设置CHEVERETO_DB的一些参数
    environment:
      CHEVERETO_DB_HOST: db
      CHEVERETO_DB_USERNAME: chevereto
      CHEVERETO_DB_PASSWORD: chevereto
      CHEVERETO_DB_NAME: chevereto
      CHEVERETO_DB_PREFIX: chv_
    # 挂载容器中的images文件夹到本地的/home/docker/chevereto/images文件夹,以及
    # 将本地的/home/docker/chevereto/conf/php.ini配置文件挂载到容器的/usr/local/etc/php/中
    volumes:
      - /home/docker/chevereto/images:/var/www/html/images:rw
      - /home/docker/chevereto/conf/php.ini:/usr/local/etc/php/php.ini:ro
    # 端口映射,本机:容器,需要配置安全组
    ports:
      - 9002:80
networks:
  chevereto-net:
volumes:
  database:
  chevereto_images:

运行容器

docker-compose up -d

设置权限

# 进入容器
docker exec -it chevereto bash
cd ~
# 批量设置权限
chmod -R 777 /var

nginx反代https访问

docker环境nginx配置https访问

Q.E.D.