1.根据实际修改docker-compose.yml文件:
version: '3.5'
services:
#mysql数据库脚本
mysql:
image: 镜像名:版本 #需要查看本地镜像进行填写。同下
container_name: mysql #容器名,同下
restart: always
ports:
- 3306:3306 #第一个3306为主机开放的端口号,第二个是镜像端口号。同下
volumes:
- ./mysql/mydir:/mydir
- ./mysql/data:/var/lib/mysql
- ./mysql/conf/my.cnf:/etc/my.cnf
- ./mysql/source:/docker-entrypoint-initdb.d/
environment:
MYSQL_ROOT_PASSWORD:密码
networks:
extnetwork:
ipv4_address: 主机IP地址
#nacos服务脚本
nacos:
image: 镜像名/nacos-server:版本
container_name: nacos
restart: always
ports:
- 8848:8848
environment:
SPRING_DATASOURCE_PLATFORM: mysql #数据源平台 仅支持mysql或不保存empty
MODE: standalone
MYSQL_SERVICE_HOST: mysql
MYSQL_SERVICE_DB_NAME: nacos_config
MYSQL_SERVICE_PORT: 3306
MYSQL_SERVICE_USER: root
MYSQL_SERVICE_PASSWORD: 密码
NACOS_APPLICATION_PORT: 8848
JVM_XMS: 512m
JVM_MMS: 256m
JVM_XMN: 128m
networks:
extnetwork:
ipv4_address: 主机IP地址
depends_on:
- mysql
#seata服务脚本
seata-server:
image: 镜像名/seata-server:版本
container_name: seata-server
restart: always
ports:
- 9200:9200
volumes:
- ./seata-server/config:/root/seata-config
environment:
SEATA_IP: 118.195.175.86
SEATA_CONFIG_NAME: file:/root/seata-config/registry
SEATA_PORT: 9200
networks:
extnetwork:
ipv4_address: 主机IP地址
depends_on:
- nacos
# rabbitmq脚本
rabbitmq:
image: 镜像:版本
container_name: rabbitmq
restart: always
ports:
- 15672:15672
- 5672:5672
volumes:
- ./rabbitmq/data:/var/lib/rabbitmq
environment:
RABBITMQ_DEFAULT_USER: admin
RABBITMQ_DEFAULT_PASS: admin
networks:
extnetwork:
ipv4_address: 主机IP地址
#redis脚本
redis:
image: 镜像名:版本
container_name: redis
restart: always
command: redis-server --requirepass root
ports:
- 6379:6379
volumes:
- ./redis/data:/data
networks:
extnetwork:
ipv4_address: 主机IP地址
#MongoDB脚本
mongodb:
image: 镜像名:版本
container_name: mongodb
restart: always
volumes:
- ./mongo/db:/data/db
- ./mongo/log:/var/log/mongodb
ports:
- 27017:27017
# environment:
# MONGO_INITDB_ROOT_USERNAME: admin
# MONGO_INITDB_ROOT_PASSWORD: admin
networks:
extnetwork:
ipv4_address: 主机IP地址
#elasticsearch脚本
elasticsearch:
image: 镜像名:版本
container_name: elasticsearch
restart: always
environment:
- "cluster.name=elasticsearch" #设置集群名称为elasticsearch
- "discovery.type=single-node" #以单一节点模式启动
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" #设置使用jvm内存大小
volumes:
- ./elasticsearch/plugins:/usr/share/elasticsearch/plugins #插件文件挂载
- ./elasticsearch/logs:/usr/share/elasticsearch/logs #插件文件挂载
- ./elasticsearch/data:/usr/share/elasticsearch/data #数据文件挂载
ports:
- 19200:9200
- 19300:9300
networks:
extnetwork:
ipv4_address: 主机IP地址
#kibana脚本
kibana:
image: 镜像名:版本
container_name: kibana
restart: always
links:
- elasticsearch:es #可以用es这个域名访问elasticsearch服务
depends_on:
- elasticsearch #kibana在elasticsearch启动之后再启动
environment:
- "elasticsearch.hosts=http://es:19200" #设置访问elasticsearch的地址
ports:
- 15601:5601
networks:
extnetwork:
ipv4_address: 主机IP地址
#minio脚本
minio:
image: 镜像/minio:版本
container_name: minio
ports:
- 9090:9000
restart: always
command: server /data
environment:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123 #大于等于8位
logging:
options:
max-size: "50M" # 最大文件上传限制
max-file: "10"
driver: json-file
volumes:
- ./minio/data:/data # 映射文件路径
networks:
extnetwork:
ipv4_address: 主机IP地址
#nginx脚本
nginx:
image: 镜像:版本
container_name: nginx
restart: always
ports:
- 80:80
privileged: true
volumes:
- ./nginx/conf/proxy.conf:/etc/nginx/proxy.conf
- ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/conf/conf.d/:/etc/nginx/conf.d/
- ./nginx/logs/:/etc/nginx/logs/
- ./nginx/home/:/home
networks:
extnetwork:
ipv4_address: 主机IP地址
2.创建挂载主目录并进入。(因为挂载目录为当前目录/镜像名)
3.将yml上传到挂载主目录并执行:
docker-compose up -d