安装docker-compose
首先,你需要找出最新版本的Docker Compose。你可以在其GitHub仓库的发布页面查看最新版本。以下命令将下载最新版本的Docker Compose到/usr/local/bin/docker-compose。请确保替换1.29.2为你查找到的最新版本号:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
设置执行权限
sudo chmod +x /usr/local/bin/docker-compose
验证安装
docker-compose --version
这条命令应该返回Docker Compose的版本号,表明它已经正确安装。
portainer
version: "3"
services:
portainer:
image: portainer/portainer:latest
container_name: portainer
ports:
- "8001:9000"
volumes:
- /home/portainer/data:/data
- /var/run/docker.sock:/var/run/docker.sock
mysql
version: '3'
services:
mysql:
image: mysql:5.7.28
restart: always
container_name: mysql
environment:
MYSQL_ROOT_PASSWORD: BKS@123456
TZ: Asia/Shanghai
ports:
- 3306:3306
volumes:
- /home/common/mysql/data:/var/lib/mysql
- /home/common/mysql/config/my.cnf:/etc/mysql/my.cnf
command:
--max_connections=1000
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--default-authentication-plugin=mysql_native_password
rabbitMQ
version: '3'
services:
rabbitmq:
image: rabbitmq:3.8-management # 使用带有管理插件的RabbitMQ镜像
hostname: rabbit
container_name: my_rabbitmq # 容器名称
volumes:
- ./data:/var/lib/rabbitmq # 挂载数据存储目录
ports:
- "5672:5672" # 映射容器内端口到宿主机
- "15672:15672"
environment:
- RABBITMQ_DEFAULT_USER=guest # 设置管理员账号和密码
- RABBITMQ_DEFAULT_PASS=guest
nacos
version: '3.7'
services:
nacos-server:
image: nacos/nacos-server:1.3.2
container_name: nacos-server
restart: always
environment:
- MODE=standalone
- SPRING_DATASOURCE_PLATFORM=mysql
- MYSQL_SERVICE_HOST=地址
- MYSQL_SERVICE_PORT=端口
- MYSQL_SERVICE_USER=用户名
- MYSQL_SERVICE_PASSWORD=密码
- MYSQL_SERVICE_DB_NAME=nacos_config
network_mode: host