docker部署
参考:
docker部署mysql+nginx+redis
docker-compose部署mysql+nginx+redis
mysql
1、创建docker-compose-mysql.yml
version: "3"
services:mysql:image: mysql:5.7restart: alwayscontainer_name: mysqlports:- 3306:3306volumes:- /home/mysql/conf:/etc/mysql/conf.d- /home/mysql/data:/var/lib/mysql- /home/mysql/log:/var/log/mysql- /etc/localtime:/etc/localtime:roenvironment: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.1restart: alwayscontainer_name: nginxports:- 8080:80volumes:- /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: redisrestart: alwayscontainer_name: redisports:- 6379:6379volumes:- /home/redis/conf/redis.conf:/etc/redis/redis.conf- /home/redis/data:/datacommand: redis-server /etc/redis/redis.conf
2、启动和停止
docker-compose -f docker-compose-redis.yml up -d
docker-compose -f docker-compose-redis.yml down