环境安装部署配置|docker-compose部署项目环境(mysql,nginx,redis)

目录结构 /home/docker/ms-docker/docker-compose.yml

version: '3' services: ms-mysql: image: mysql:5.7 restart: always ports: - '3306:3306' networks: - front-ms privileged: true container_name: ms-mysql environment: - "MYSQL_ROOT_PASSWORD=数据库密码" - "MYSQL_DATABASE=数据库" - "TZ=Asia/Shanghai" command: --default-time-zone='+8:00' volumes: - $PWD/data/mysql:/var/lib/mysql - $PWD/conf/mysql/init:/docker-entrypoint-initdb.d/ - $PWD/conf/mysql/conf.d:/etc/mysql/conf.d ms-redis: image: redis:5.0-alpine restart: always ports: - '6379:6379' networks: - front-ms privileged: true environment: - "TZ=Asia/Shanghai" container_name: ms-redis volumes: - $PWD/data/redis:/data command: redis-server --requirepass 密码 --appendonly yes nginx: image: nginx container_name: 'nginx' privileged: true restart: always ports: - '80:80' - '443:443' ##SSL volumes: - $PWD/logs/nginx/logs:/var/log/nginx - $PWD/conf/nginx/conf.d/nginx.conf:/etc/nginx/nginx.conf - $PWD/app/www/:/usr/share/nginx/html - $PWD/conf/nginx/域名.pem:/ssl/域名.pem##SSL - $PWD/conf/nginx/域名.key:/ssl/域名.key##SSL - $PWD/app/https:/home/https command: /bin/bash -c "nginx -g 'daemon off; '" networks: front-ms: driver: bridge

常用命令 【环境安装部署配置|docker-compose部署项目环境(mysql,nginx,redis)】docker-compose up -d 加载全部镜像
docker-compose up -d nginx 重新加载nginx镜像
docker-compose stop nginx 停止nginx镜像
docker-compose start nginx 开启nginx镜像
docker-compose restart nginx 重启nginx镜像

    推荐阅读