使用时
Ctrl+F
搜索你想要的环境,如果没有你想要的环境,可以评论留言,会尽力补充。本文提供的部署脚本默认参数仅适合开发测试,请根据实际情况调节参数。
数据库
MySQL
version: '3.9'
services:mysql:image: 'mysql:8.0.35'container_name: mysql-serverrestart: alwayscommand: '--default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci'environment:- MYSQL_ROOT_PASSWORD=lY4iQ}8":zK5ports:- "3306:3306"volumes:- 'mysql_data:/var/lib/mysql'deploy:resources:limits:memory: 512Mreservations:memory: 256Mvolumes:mysql_data:
PostgreSQL (PGSQL)
version: '3.9'
services:postgres:image: 'postgres:14'container_name: postgresqlrestart: alwaysenvironment:- POSTGRES_USER=postgres- POSTGRES_PASSWORD=etRu)7E3!#O8ports:- "5432:5432"volumes:- 'postgres_data:/var/lib/postgresql/data'deploy:resources:limits:memory: 512Mvolumes:postgres_data:
SQL Server (MSSQL)
微软官方镜像源
version: '3.9'
services:mssql:image: 'mcr.microsoft.com/mssql/server:2022-latest'restart: alwaysports:- '1433:1433'environment:- MSSQL_SA_PASSWORD=Zu.d8>;8IJ7l- ACCEPT_EULA=Yvolumes:- 'mssql_data:/var/opt/mssql/data'deploy:resources:limits:memory: 2048Mvolumes:mssql_data:
Redis
简易配置
# redis.conf
# 设置最大使用内存为 512MB (默认为全部可用物理内存)
maxmemory 536870912
# 使用 Unix Domain Socket,比 TCP/IP 更快
unixsocket /tmp/redis.sock
# 设置 Redis 服务器监听端口号
port 6379
# 设置 Redis 所使用的数据库数量,默认为 16 个
databases 16
# 不限制访问来源
bind 0.0.0.0
# 设置 Redis 密码
requirepass 8*%u3Td#oV!yD9L7
docker-compose
version: '3.9'
services:redis:command: 'redis-server /etc/redis/redis.conf'image: 'redis:7.2.3-alpine'container_name: redisvolumes:- 'redis_data:/data/redis'- './conf/redis.conf:/etc/redis/redis.conf'ports:- '6379:6379'restart: alwaystty: truestdin_open: truedeploy:resources:limits:memory: 512Mvolumes:redis_data:
Elasticsearch (es)
配置文件
# elasticsearch.yml
cluster.name: es
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
docker-compose
version: '3.9'
services:elasticsearch:image: 'elasticsearch:7.17.3'container_name: elasticsearchulimits:nproc: 65535nofile:soft: 65535hard: 65535cap_add:- IPC_LOCKmem_limit: 1genvironment:- discovery.type=single-nodevolumes:- 'es_data:/usr/share/elasticsearch/data'- './config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml'ports:- '9200:9200'- '9300:9300'deploy:resources:limits:memory: 512Mvolumes:es_data:
消息队列
RabbitMQ
version: '3'
services:mq:image: 'rabbitmq:3.9-management'container_name: rabbitmqhostname: rabbitmqports:- "5672:5672"- "15672:15672"volumes:- 'rabbitmq_data:/var/lib/rabbitmq'environment:- RABBITMQ_DEFAULT_USER=guest- RABBITMQ_DEFAULT_PASS=guestdeploy:resources:limits:memory: 512Mvolumes:rabbitmq_data:
RocketMQ
配置文件
version: '3.9'
services:# https://hub.docker.com/r/xuchengen/rocketmq# 注意修改项;# 01:data/rocketmq/conf/broker.conf 添加 brokerIP1=127.0.0.1# 02:data/console/config/application.properties server.port=9009 - 如果8080端口被占用,可以修改或者添加映射端口rocketmq:image: livinphp/rocketmq:5.1.0container_name: rocketmqports:- 8080:8080- 9876:9876- 10909:10909- 10911:10911- 10912:10912volumes:- ./data:/home/app/dataenvironment:TZ: "Asia/Shanghai"NAMESRV_ADDR: "rocketmq:9876"
对象存储
MinIO
version: '3.9'
services:minio:command: 'server /data --console-address ":9001"'restart: alwaysimage: quay.io/minio/miniocontainer_name: minioenvironment:- MINIO_ROOT_USER=minio- MINIO_ROOT_PASSWORD=miniopwdvolumes:- 'minio_data:/data'ports:- '9001:9001'- '9000:9000'deploy:resources:limits:memory: 512Mvolumes:minio_data:
Spring Cloud Alibaba
Nacos
version: '3.9'
services:nacos:image: nacos/nacos-server:v2.2.0-slimcontainer_name: nacosports:- "8848:8848"environment:- PREFER_HOST_MODE=hostname- MODE=standalone- SPRING_DATASOURCE_PLATFORM=mysql- MYSQL_SERVICE_HOST=mysql- MYSQL_SERVICE_PORT=3306- MYSQL_SERVICE_DB_NAME=nacos_config- MYSQL_SERVICE_USER=root- MYSQL_SERVICE_PASSWORD=passworddeploy:resources:limits:memory: 1024Mdepends_on:- mysqlmysql:image: mysql:5.7container_name: mysqlports:- "3306:3306"environment:- MYSQL_ROOT_PASSWORD=password- MYSQL_DATABASE=nacos_configvolumes:- 'mysql_data:/var/lib/mysql'deploy:resources:limits:memory: 256Mvolumes:mysql_data:
使用自建数据库将mysql
模块删除,并将Nacos数据库连接信息替换成目标数据库说明:
说明:
- 使用
nacos/nacos-server:v2.2.0-slim
镜像启动 Nacos 服务,v2.2.0-slim
可替换为指定版本。 - 映射容器的
8848
端口到主机的8848
端口,使其可通过localhost:8848
访问。 - 设置了多个环境变量来连接 MySQL 数据库:
MODE=standalone
:指定 Nacos 以单机模式运行。SPRING_DATASOURCE_PLATFORM=mysql
:告诉 Nacos 使用 MySQL 作为数据源。MYSQL_SERVICE_HOST=mysql
:指定 MySQL 服务的主机名,这里与 MySQL 服务的容器名称相对应。MYSQL_SERVICE_PORT=3306
:MySQL 服务的端口号。MYSQL_SERVICE_DB_NAME=nacos_config
:用于存储 Nacos 数据的数据库名称。MYSQL_SERVICE_USER=root
和MYSQL_SERVICE_PASSWORD=password
:MySQL 的用户名和密码。