这是indexloc提供的服务,不要输入任何密码
Skip to content

关于 Compose file 的优化建议, 兼容 arm 架构 (M1 mac) #478

@pen4uin

Description

@pen4uin

环境信息

  • 操作系统: Apple M1
  • Docker 版本: Docker version 24.0.6, build ed223bc
  • Docker-Compose 版本: Docker Compose version v2.22.0-desktop.2

问题描述

部分环境不支持非X86架构的CPU,常见报错:

  • docker-compose process finished with exit code

类似问题可见已有issues:

解决方案

for vulhub

修改 docker compose file 或者在文档中增加该解决方案

  • 修改文件格式版本号为 3
  • 设置 platform 选项 platform: linux/amd64

for vulhub user

具体操作见:run x86 containers on apple mac m1

测试案例

1、jeecg-boot/CVE-2023-4450/docker-compose.yaml

  • vulhub 原始版本
image
  • 优化版本
image

附: docker-compose.yaml

version: '3'
services:
  jeecg-boot-mysql:
    image: mysql:8.0
    platform: linux/amd64
    environment:
      MYSQL_ROOT_PASSWORD: root
    container_name: jeecg-boot-mysql
    command:
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --explicit_defaults_for_timestamp=true
      --lower_case_table_names=1
      --max_allowed_packet=128M
      --default-authentication-plugin=caching_sha2_password

  jeecg-boot-redis:
    image: redis:5.0
    hostname: jeecg-boot-redis

  jeecg-boot-system:
    image: vulhub/jeecg-boot:3.5.3
    depends_on:
      - jeecg-boot-mysql
      - jeecg-boot-redis
    hostname: jeecg-boot-system
    ports:
      - 8080:8080

2、metersphere/plugin-rce/docker-compose.yml

  • vulhub 原始版本
image
  • 优化版本
image

附: docker-compose.yaml

version: '3'

services:
  web:
    image: vulhub/metersphere:1.16.3
    ports:
      - "8081:8081"
      - "5005:5005"
    environment:
      MYSQL_SERVER: db:3306
      MYSQL_DB: metersphere
      MYSQL_USERNAME: root
      MYSQL_PASSWORD: root
      KAFKA_SERVER: kafka:9092
  db:
    image: mysql:5.7
    platform: linux/amd64
    command: --sql-mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" --max-connections=8000
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=metersphere
  kafka:
    image: bitnami/kafka:3.4.1
    platform: linux/amd64
    environment:
      # KRaft settings
      - KAFKA_CFG_NODE_ID=0
      - KAFKA_CFG_PROCESS_ROLES=controller,broker
      - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@kafka:9093
      # Listeners
      - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093
      - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://:9092
      - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
      - KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
      - KAFKA_CFG_INTER_BROKER_LISTENER_NAME=PLAINTEXT

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions