Featured image of post Mac上常用的支持Arm架构的镜像(持续更新)

Mac上常用的支持Arm架构的镜像(持续更新)

前言

最开始的Mac用的是intel的cpu,后来使用了基于Arm架构自研的苹果芯片,在使用虚拟化时需要使用支持Arm架构的镜像。在日常使用中经常会使用Docker来构建一些环境,便发现有时候需要自己去构建镜像或者官方提供的镜像并没有支持Arm架构的,所以需要参考官方Github仓库上的Dockerfile来构建适合Arm架构的镜像。以下记录了在使用MacBook过程中用到的一些比较基础的镜像。

个人环境:M2 + OrbStack

Maven

1、maven3 jdk8镜像:maven:3-openjdk-8

镜像的操作系统是debain,并且安装了很多常用包,例如:unzip、curl、wget等。具体可查看

https://hub.docker.com/layers/library/maven/3-openjdk-8/images/sha256-29cc4c106af036b3727fad911174511d5af3103710419e1fd3d0718aa217f7ae?context=explore

有带slim的镜像,如:maven:3-openjdk-8-slim,镜像体积较小,比不带slim的镜像少一些命令。如果仅用到maven和jdk建议使用带silm的,因为体积小。

2、maven3 jdk11镜像:3-openjdk-11

同上

Open JDK

这个发行的版本有很多。我自己一般使用eclipse-temurin。因为在Docker Hub上的 Overview 上可以直接点tag链接,跳转到支持Arm架构的JDK镜像。不用自己在Openjdk那里一页页地找。

1、arm64v8/eclipse-temurin:8-jdk。镜像的操作系统是Ubuntu。

2、arm64v8/eclipse-temurin:8-jre。仅包含java运行环境,镜像更小,操作系统也是Ubuntu。

3、arm64v8/eclipse-temurin:11-jdk。

4、arm64v8/eclipse-temurin:11-jre。

5、arm64v8/eclipse-temurin:17-jdk。

6、arm64v8/eclipse-temurin:17-jre。

等。。。

也可以使用含有maven和jdk的镜像,毕竟可能在构建镜像的时候会需要maven来构建项目。

Nginx

Nginx的镜像跟eclipse-temurin 一样在Overview上可以看到支持的CPU架构,很轻松就能找到。https://hub.docker.com/r/arm64v8/nginx/tags

例如:1.24.0-alpine3.17-perl

Tomcat

Docker Hub页面

例如:

1、arm64v8/tomcat:8.5-jre8-temurin-focal。看名字大概是基于eclipse-temurin:8-jre-focal镜像的Tomcat 8.5。

2、arm64v8/tomcat:8-jdk8。带有完整jdk8环境

3、arm64v8/tomcat:9.0-jre8-temurin-focal。tomcat9.0版本,jre8运行环境。

4、arm64v8/tomcat:9.0-jdk8-temurin-focal。同理。

等。。。

Redis

基本常用的架构都支持。

Mark一下免得再去Docker Hub找:redis:6.2.7redis:7.2.3

Redis Docker Compose

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
version: '3.3'
services:
  redis6379:
    #network_mode: 'host'
    image: redis:6.2.7
    container_name: redis
    # restart: always
    #logging:
    #  driver: 'json-file'
    #  options:
    #    max-size: '5g'
    ports:
      - 6379:6379
    volumes:
      - ./data:/data
      - ./redis.conf:/usr/local/etc/redis/redis.conf
      - ./logs:/logs
    command: redis-server /usr/local/etc/redis/redis.conf

MySQL

同redis一样。在Docker Hub上没找到自持Arm架构的5.7版本的MySQL。那就用8.0版本吧。

镜像:mysql:latestmysql:8.0.35-bullseye

MySQL Docker Compose

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
version: '3'
services:
  mysql:
    image: mysql:latest
    #restart: always
    container_name: mysql
    hostname: mysql
    environment:
      MYSQL_ROOT_PASSWORD: 123456
      TZ: Asia/Shanghai
    ports:
      - 3306:3306
    volumes:
      - ./data:/var/lib/mysql
      - ./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
    healthcheck:
      test: ["CMD-SHELL", "curl --silent localhost:3306 >/dev/null || exit 1"]
      interval: 10s
      timeout: 10s
      retries: 3

Nacos

看了一下Docker Hub上的镜像,latest的镜像不支持arm架构,而且带slim的才支持。Github 上 Nacos Docker仓库

例如:nacos/nacos-server:v2.3.0-slimnacos/nacos-server:v1.4.6-slim

或者自行构建:

https://github.com/nacos-group/nacos-docker/blob/master/build/Dockerfile

https://github.com/nacos-group/nacos-docker/blob/master/build/Dockerfile.Slim

Nacos Docker Compose

参考:https://github.com/nacos-group/nacos-docker/blob/master/example/standalone-derby.yaml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
version: "3"
services:
  nacos:
    image: nacos/nacos-server:v2.2.3-slim
    container_name: nacos-standalone
    environment:
      - PREFER_HOST_MODE=hostname
      - MODE=standalone
      - NACOS_AUTH_ENABLE=false
      - NACOS_AUTH_TOKEN=SecretKey012345678901234567890123456789012345678901234567890123456789
      - NACOS_AUTH_IDENTITY_KEY=123456781099999
      - NACOS_AUTH_IDENTITY_VALUE=12345678109999909089
    volumes:
      - ./standalone-logs/:/home/nacos/logs
      - ./init.d/custom.properties:/home/nacos/init.d/custom.properties
    ports:
      - "8848:8848"
      - "9848:9848"

Zookeeper

基本上都支持,选择最新的zookeeper:latest或者指定版本zookeeper:3.8

Zookeeper Docker Compose

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
version: "3"

services:
  zookeeper1:
    image: zookeeper:3.8
    container_name: zoo1
    hostname: zoo1
    environment:
      - ALLOW_ANONYMOUS_LOGIN=yes
      - ZOO_SERVER_ID=1
      #- ZOO_SERVERS=zoo1:2888:3888;zookeeper2:2888:3888;zookeeper3:2888:3888
    volumes:
      - "./zoo1/data:/data"
      - "./zoo1/datalog:/datalog"
      - "./zoo1/conf:/conf"
    ports:
      - '2181:2181'
      - '2888:2888'
      - '3888:3888'

dubbo-admin

1、apache/dubbo-admin:0.5.0-SNAPSHOT,Docker Hub上有,直接拉就行docker pull apache/dubbo-admin:0.5.0-SNAPSHOT

2、自行构建,dubbo-admin官方git仓库提供的Dockerfile用到了maven:3-openjdk-8openjdk:8-jdk都是支持Arm架构的。

  • git clone https://github.com/apache/dubbo-admin.git
  • cd dubbo-admin/docker/latest
  • docker build -t apache/dubbo-admin:latest .

dubbo-admin Docker Compose

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
version: "3"

services:
  dubbo-admin:
    image: apache/dubbo-admin:latest
    container_name: dubbo-admin
    hostname: dubbo-admin
    ports:
      - '8080:8080'
    environment:
      - admin.registry.address=zookeeper://127.0.0.1:2181
      - admin.config-center=zookeeper://127.0.0.1:2181
      - admin.metadata-report.address=zookeeper://127.0.0.1:2181

RocketMQ

很遗憾,支持Arm架构的镜像是一个都没有。有一个apache/rocketmq-operator:latest在K8S上创建RocketMQ的,不太适合在本地使用。

自行构建RocketMQ

用到的基础镜像是:eclipse-temurin:8-jdk-centos7支持Arm架构。

  1. git clone https://github.com/apache/rocketmq-docker.git
  2. cd rocketmq-docker/image-build
  3. 指定版本,通过指定版本号,构建自己想要的版本。
    • 指定 4.9.4 版本:sh build-image.sh 4.9.4 centos
    • 指定 5.1.2 版本:sh build-image.sh 5.1.4 centos
  4. 构建rocketmq-dashboard
    • sh build-image-dashboard.sh 1.0.0 centos

RocketMQ Docker Compose

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
version: '3'
services:
  #Service for nameserver
  namesrv:
    image: apache/rocketmq:4.9.4
    container_name: namesrv
    ports:
      - 9876:9876
    volumes:
      - ./namesrv/logs:/home/rocketmq/logs
    command: sh mqnamesrv

  #Service for broker
  brokera:
    image: apache/rocketmq:4.9.4
    container_name: rmqbroker-a
    links:
      - namesrv
    ports:
      - 10909:10909
      - 10911:10911
      - 10912:10912
    environment:
      - NAMESRV_ADDR=namesrv:9876
    volumes:
      - ./data-a/broker/logs:/home/rocketmq/logs
      - ./data-a/broker/store:/home/rocketmq/store
      - ./data-a/broker/conf/broker.conf:/opt/rocketmq-ROCKETMQ_VERSION/conf/broker.conf
    command: sh mqbroker -c /opt/rocketmq-ROCKETMQ_VERSION/conf/broker.conf

  #Service for another broker -- broker1
  brokerb:
    image: apache/rocketmq:4.9.4
    container_name: rmqbroker-b
    links:
      - namesrv
    ports:
      - 10929:10909
      - 10931:10911
      - 10932:10912
    environment:
      - NAMESRV_ADDR=namesrv:9876
    volumes:
      - ./data-b/broker/logs:/home/rocketmq/logs
      - ./data-b/broker/store:/home/rocketmq/store
      - ./data-b/broker/conf/broker.conf:/opt/rocketmq-ROCKETMQ_VERSION/conf/broker.conf
    command: sh mqbroker -c /opt/rocketmq-ROCKETMQ_VERSION/conf/broker.conf
  # service for rocketmq dashboard
  dashboard:
    image: apache/rocketmq-dashboard:1.0.0-centos
    container_name: dashboard
    ports:
      - 8989:8080
    links:
      - namesrv
    depends_on:
      - namesrv
    environment:
      - NAMESRV_ADDR=namesrv:9876

Seatunnel

Update at 2023/12/20

Seatunnel 高性能、分布式、海量数据集成工具,支持很多的数据源。官网:https://seatunnel.apache.org/

docker hub上没有官方的镜像,有一些个人构建推上去,但是觉得不太适合,他们是做了添加jar到镜像里面去的。下面是个人构建过程,更加的适用。

1、Dockerfile

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
FROM openjdk:8

ARG version
RUN mkdir -p /opt/seatunnel && mkdir -p /opt/jobs
ADD ./apache-seatunnel-${version} /opt/seatunnel/
ENV SEATUNNEL_HOME=/opt/seatunnel
EXPOSE 5801
WORKDIR /opt/seatunnel
# cluster-mode 方式运行
ENTRYPOINT ["/bin/sh", "-c", " ${SEATUNNEL_HOME}/bin/seatunnel-cluster.sh"]

2、编写shell脚本:build-image.sh,此脚本仅适用于seatunnel 2.3.2及以上。因为更早的版本的二进制压缩包名称不一样。执行wget更低版本的会404。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash

checkVersion() {
    echo "Version = $1"
	echo $1 |grep -E "^[0-9]+\.[0-9]+\.[0-9]+" > /dev/null
    if [ $? = 0 ]; then
        return 1
    fi

	echo "Version $1 illegal, it should be X.X.X format(e.g. 2.3.0), please check released versions in 'https://seatunnel.apache.org/download/'"
    exit -1
}

SEATUNNEL_VERSION=$1

checkVersion $SEATUNNEL_VERSION

wget https://archive.apache.org/dist/seatunnel/${SEATUNNEL_VERSION}/apache-seatunnel-${SEATUNNEL_VERSION}-bin.tar.gz
tar -xzvf apache-seatunnel-${SEATUNNEL_VERSION}-bin.tar.gz && rm -f apache-seatunnel-${SEATUNNEL_VERSION}-bin.tar.gz
# 需要进入到seatunnel目录里执行
cd apache-seatunnel-${SEATUNNEL_VERSION} && mkdir logs
# 注意一定要修改 config 目录下的 plugin_config,默认是会有很多connector,导致安装很慢因为要下载很多jar包。按需即可
cat>config/plugin_config<<EOF
--connectors-v2--
connector-assert
connector-cdc-mysql
connector-jdbc
connector-redis
connector-socket
--end--
EOF

sh bin/install-plugin.sh ${SEATUNNEL_VERSION}
# Dockerfile放在seatunnel目录同一级
cd ../
# Build image
docker build --no-cache -t apache/seatunnel:${SEATUNNEL_VERSION} --build-arg version=${SEATUNNEL_VERSION} .

3、执行命令,例如构建2.3.3的版本。

1
2
chmod +x build-image.sh
sh build-image.sh 2.3.3

Seatunnel Docker Compose

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
version: '3'
services:
  seatunnel:
    image: apache/seatunnel:2.3.3
    #restart: always
    container_name: seatunnel
    hostname: seatunnel
    volumes:
      # 挂载任务配置文件
      - ./jobs:/opt/jobs
      - ./logs:/opt/seatunnel/logs

To be continue