一.离线安装Docker Compose
1.下载安装包Docker Compose
https://github.com/docker/compose/releases/download
2.上传到服务器
mv /bwss/upload/docker-compose-linux-aarch64 /usr/local/bin/
|
3.创建软链接以便于从任何位置调用 docker-compose
命令
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
4.测试安装情况
|
二.安装中间件
docker-compose.yml配置
version: '3'
services:
mysql:
image: mysql:5.7.30
container_name: test-mysql
ports:
- "3307:3306"
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: database_test
MYSQL_USER: admin
MYSQL_PASSWORD: admin123456
restart: always
redis:
image: redis:7.2.0
container_name: test-redis
ports:
- "6380:6379"
restart: always
volumes:
- /bwss/docker_test/config/redis/conf/redis.conf:/etc/redis/redis.conf
- /bwss/docker_test/config/redis/data:/data
command: redis-server /etc/redis/redis.conf
nginx:
image: nginx:1.25.5
container_name: test-nginx
ports:
- "8088:80" # 将主机的80端口映射到容器的80端口
restart: always
volumes:
- /bwss/docker_test/config/nginx/nginx.conf:/etc/nginx/nginx.conf # 如果需要自定义Nginx配置,可以挂载配置文件
- /bwss/agent:/bwss/agent # 挂载你的网站文件到Nginx的默认web根目录
mosquitto:
image: eclipse-mosquitto:2.0.18
container_name: test-mosquitto
ports:
- "1884:1883"
restart: always
volumes:
- /bwss/docker_test/config/mosquitto/conf:/mosquitto/config
- /bwss/docker_test/config/mosquitto/data:/mosquitto/data
mongodb:
image: mongo:4.4
container_name: test-mongodb
ports:
- "27018:27017"
restart: always
volumes:
- /bwss/docker_test/config/mongodb/db:/data/db
- /bwss/docker_test/config/mongodb/conf:/data/configdb
- /bwss/docker_test/config/mongodb/init/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js
执行以上脚本即可自动安装nginx,mysql,redis等中间件容器
执行脚本指令:docker-compose up -d
具体见附件包资源:https://download.csdn.net/download/x948130516/89396990
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » 使用Docker Compose部署包含MySQL、Redis、Nginx和Mosquitto的容器
发表评论 取消回复