大家好,我是考100分的小小码 ,祝大家学习进步,加薪顺利呀。今天说一说Docker-compose常用软件部署(mysql、redis、rabbitmq),希望您对编程的造诣更进一步.
Docker-compose常用软件部署(mysql、redis、rabbitmq)
废话不多说,下面就直接给出部署文件已经启动脚本,这个会持续更新。以下的部署方式均是单例部署。高可用或者其他部署方案我会单独写相应的文章。
- mysql数据库
- redis缓存
- rabbitmq消息队列
compose-mysql.yaml
version: ‘3‘
# docker network create mysql_bridge
networks:
mysql_bridge:
driver: bridge
services:
mysql-server:
image: docker.io/mysql:5.7
container_name: mysql-server
restart: always
environment:
# 指定root密码。不指定则会启动失败
- MYSQL_ROOT_PASSWORD:123456
volumes:
# 同步本地时间
- /etc/localtime:/etc/localtime:ro
# 初始化执行的sql
# - ./init:/docker-entrypoint-initdb.d/
# db配置
- ./conf/my.cnf:/etc/my.cnf
# db文件存放地址
- ./db_data:/var/lib/mysql
ports:
- 3306:3306
networks:
- mysql_bridge
代码100分
start-mysql.sh
代码100分#! /usr/bin/bash
# 定义一个名称变量
network_name="mysql_bridge"
filterName=`docker network ls | grep $network_name | awk ‘{ print $2 }‘`
if [ "$filterName" == "" ]; then
# 不存在就创建
docker network create $network_name
echo "Created network $network_name success!!"
fi
docker-compose -f ./compose-mysql.yaml up -d
docker ps -a
docker logs -f mysql-server
compose-redis.yaml
version: ‘3‘
# docker network create redis_bridge
networks:
redis_bridge:
driver: bridge
services:
redis-server:
image: docker.io/redis:latest
container_name: redis-server
restart: always
command: redis-server --requirepass "123456"
volumes:
- /etc/localtime:/etc/localtime:ro
- ./redis_data:/var/lib/redis
ports:
- 6379:6379
networks:
- redis_bridge
start-redis.sh
代码100分#! /usr/bin/bash
# 定义一个名称变量
network_name="redis_bridge"
filterName=`docker network ls | grep $network_name | awk ‘{ print $2 }‘`
if [ "$filterName" == "" ]; then
# 不存在就创建
docker network create $network_name
echo "Created network $network_name success!!"
fi
docker-compose -f ./compose-redis.yaml up -d
docker ps -a
docker logs -f redis-server
compose-rabbitmq.yaml
version: ‘3‘
# docker network create rabbitmq_bridge
networks:
rabbitmq_bridge:
driver: bridge
services:
rabbitmq:
image: rabbitmq:management-alpine
container_name: rabbitmq-server
restart: always
volumes:
- /etc/localtime:/etc/localtime:ro
- ./data:/var/lib/rabbitmq
environment:
- RABBITMQ_DEFAULT_USER=ming
- RABBITMQ_DEFAULT_PASS=ming123456
ports:
- "15672:15672"
- "5672:5672"
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
networks:
- rabbitmq_bridge
start-rabbitmq.sh
#! /usr/bin/bash
# 定义一个名称变量
network_name="rabbitmq_bridge"
filterName=`docker network ls | grep $network_name | awk ‘{ print $2 }‘`
if [ "$filterName" == "" ]; then
# 不存在就创建
docker network create $network_name
echo "Created network $network_name success!!"
fi
docker-compose -f ./compose-rabbitmq.yaml up -d
docker ps -a
docker logs -f rabbitmq-server
Docker-compose常用软件部署(mysql、redis、rabbitmq)
原文地址:https://www.cnblogs.com/jockming/p/13336713.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/7276.html