docker-compose部署mysql+nginx+redis

docker部署

参考:
docker部署mysql+nginx+redis

docker-compose部署mysql+nginx+redis

mysql

1、创建docker-compose-mysql.yml

version: "3"
services:
  mysql:
    image: mysql:5.7
    restart: always
    container_name: mysql
    ports:
      - 3306:3306
    volumes:
      - /home/mysql/conf:/etc/mysql/conf.d
      - /home/mysql/data:/var/lib/mysql
      - /home/mysql/log:/var/log/mysql
	  - /etc/localtime:/etc/localtime:ro
    environment:
      MYSQL_ROOT_PASSWORD: root

2、启动和停止

docker-compose -f docker-compose-mysql.yml up -d
docker-compose -f docker-compose-mysql.yml down

nginx

1、创建docker-compose-nginx.yml

version: "3"
services:
  nginx:
    image: nginx:1.20.1
    restart: always
    container_name: nginx
    ports:
      - 8080:80
    volumes:
      - /home/nginx/html:/usr/share/nginx/html:ro
      - /home/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
      - /home/nginx/conf/conf.d:/etc/nginx/conf.d
	  - /home/nginx/log:/var/log/nginx

2、启动和停止

docker-compose -f docker-compose-nginx.yml up -d
docker-compose -f docker-compose-nginx.yml down

redis

1、创建docker-compose-redis.yml

version: "3"
services:
  redis:
    image: redis
    restart: always
    container_name: redis
    ports:
      - 6379:6379
    volumes:
      - /home/redis/conf/redis.conf:/etc/redis/redis.conf
      - /home/redis/data:/data
    command: redis-server /etc/redis/redis.conf

2、启动和停止

docker-compose -f docker-compose-redis.yml up -d
docker-compose -f docker-compose-redis.yml down
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值