一.离线安装Docker Compose

    1.下载安装包Docker Compose

https://github.com/docker/compose/releases/download

https://objects.githubusercontent.com/github-production-release-asset-2e65be/15045751/93aa98bb-8fce-4c53-bc53-7ce2ecb1a872?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240528%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240528T084437Z&X-Amz-Expires=300&X-Amz-Signature=4617d4aff81fbb29acefe0f22091ef8122ea7f4c0d818c8345cd78c33e077914&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=15045751&response-content-disposition=attachment%3B%20filename%3Ddocker-compose-linux-aarch64&response-content-type=application%2Foctet-stream

2.上传到服务器

mv /bwss/upload/docker-compose-linux-aarch64 /usr/local/bin/

sudo chmod +x docker-compose

3.创建软链接以便于从任何位置调用 docker-compose 命令

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

4.测试安装情况

docker-compose --version

二.安装中间件

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

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部