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

你可能感兴趣的:(运维,mysql,nginx,docker-compose,redis)