打包docker image的时候报错- pulsar-1.10.1

打包docker image的时候报错- pulsar-1.10.1

使用命令: 报错出现在第二个命令。

mvn clean install -DskipTests
mvn package -Pdocker,-main -am -pl docker/pulsar-all -DskipTests
....
[INFO]  ---> Using cache
[INFO]  ---> 3baecab2ee67
[INFO] Step 16/28 : ARG UBUNTU_MIRROR=mirror://mirrors.ubuntu.com/mirrors.txt
[INFO]
[INFO]  ---> Using cache
[INFO]  ---> b07a6184b558
[INFO] Step 17/28 : RUN sed -i "s|http://archive\.ubuntu\.com/ubuntu/|${UBUNTU_MIRROR:-mirror://mirrors.ubuntu.com/mirrors.txt}|g" /etc/apt/sources.list      && apt-get update      && apt-get -y dist-upgrade      && apt-get -y install --no-install-recommends openjdk-11-jdk-headless netcat dnsutils less procps iputils-ping                  python3 python3-kazoo python3-pip                  curl ca-certificates      && apt-get -y --purge autoremove      && apt-get autoclean      && apt-get clean      && rm -rf /var/lib/apt/lists/*
[INFO]
[INFO]  ---> Running in b58ab7f7bb10
[INFO] Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
[INFO] Get:2 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [2036 kB]
[INFO] Get:3 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [1401 kB]
[INFO] Get:4 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [885 kB]
[INFO] Get:5 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [27.5 kB]
[INFO] Err:6 http://mirrors.ubuntu.com/mirrors.txt Mirrorlist
[INFO]   Could not connect to mirrors.ubuntu.com:80 (91.189.90.8), connection timed out
[INFO] Ign:7 mirror://mirrors.ubuntu.com/mirrors.txt focal InRelease
[INFO] Ign:8 mirror://mirrors.ubuntu.com/mirrors.txt focal-updates InRelease
[INFO] Ign:9 mirror://mirrors.ubuntu.com/mirrors.txt focal-backports InRelease
[INFO] Err:10 mirror://mirrors.ubuntu.com/mirrors.txt focal Release
[INFO]   Downloading mirror file failed
[INFO] Err:11 mirror://mirrors.ubuntu.com/mirrors.txt focal-updates Release
[INFO]   Downloading mirror file failed
[INFO] Err:12 mirror://mirrors.ubuntu.com/mirrors.txt focal-backports Release
[INFO]   Downloading mirror file failed
[INFO] Reading package lists...
[INFO]
[INFO] E: The repository 'mirror://mirrors.ubuntu.com/mirrors.txt focal Release' does not have a Release file.
[INFO] E: The repository 'mirror://mirrors.ubuntu.com/mirrors.txt focal-updates Release' does not have a Release file.
[INFO] E: The repository 'mirror://mirrors.ubuntu.com/mirrors.txt focal-backports Release' does not have a Release file.
[INFO]
[ERROR] The command '/bin/sh -c sed -i "s|http://archive\.ubuntu\.com/ubuntu/|${UBUNTU_MIRROR:-mirror://mirrors.ubuntu.com/mirrors.txt}|g" /etc/apt/sources.list      && apt-get update      && apt-get -y dist-upgrade      && apt-get -y install --no-install-recommends openjdk-11-jdk-headless netcat dnsutils less procps iputils-ping                  python3 python3-kazoo python3-pip                  curl ca-certificates      && apt-get -y --purge autoremove      && apt-get autoclean      && apt-get clean      && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Pulsar 2.10.1:
[INFO]
[INFO] Pulsar ............................................. SUCCESS [ 36.391 s]
[INFO] Apache Pulsar :: Docker Images ..................... SUCCESS [  0.043 s]
[INFO] Apache Pulsar :: Docker Images :: Pulsar Latest Version FAILURE [22:01 min]
[INFO] Apache Pulsar :: Docker Images :: Pulsar Latest Version (Include All Components) SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  22:38 min
[INFO] Finished at: 2022-08-01T15:51:09+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.4.13:build (default) on project pulsar-docker-image: Could not build image: The command '/bin/sh -c sed -i "s|http://archive\.ubuntu\.com/ubuntu/|${UBUNTU_MIRROR:-mirror://mirrors.ubuntu.com/mirrors.txt}|g" /etc/apt/sources.list      && apt-get update      && apt-get -y dist-upgrade      && apt-get -y install --no-install-recommends openjdk-11-jdk-headless netcat dnsutils less procps iputils-ping                  python3 python3-kazoo python3-pip                  curl ca-certificates      && apt-get -y --purge autoremove      && apt-get autoclean      && apt-get clean      && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :pulsar-docker-image

看日志是提示网络问题,可以尝试用Github Action来打包镜像, 下面仓库是我基于官方仓库Action修改后用来打包开发镜像的Action,参考:

1 Like

这个问题确定是网络问题。我没有做任何修改的情况下,再次运行了一次,成功了。

如果在 Step 17/28 : RUN sed -i … 里面加入重试,应该是个不错的改进。

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Pulsar 2.10.1:
[INFO]
[INFO] Pulsar ............................................. SUCCESS [ 32.839 s]
[INFO] Apache Pulsar :: Docker Images ..................... SUCCESS [  0.037 s]
[INFO] Apache Pulsar :: Docker Images :: Pulsar Latest Version SUCCESS [12:19 min]
[INFO] Apache Pulsar :: Docker Images :: Pulsar Latest Version (Include All Components) SUCCESS [02:59 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  15:52 min
[INFO] Finished at: 2022-08-01T23:43:05+08:00
[INFO] ------------------------------------------------------------------------