在 Docker 运行容器的时候,发现容器无法启动,通过 docker logs 指令查看到了如下的错误:
standard_init_linux.go:211: exec user process caused “no such file or directory”
这个错误其实是 docker 镜像的平台和宿主机的平台架构不一致引起的,如你拉取的镜像是 amd64 平台的,但宿主机是 arm64 架构,就会产生该问题
那么如何解决这个错误呢,直入正题:
Maven 方式我的项目基于 maven 构建,构建配置如下:
我打包的 maven 镜像默认是 amd64 版本的,只需要把 properties 的 jib-maven-plugin.architecture 改成 arm64 版本即可
docker build 方式1.8 3.1.4 eclipse-temurin:11-jre-focal arm64 3.3.2 spring-boot:run org.springframework.boot spring-boot-maven-plugin com.google.cloud.tools jib-maven-plugin com.google.cloud.tools jib-maven-plugin ${jib-maven-plugin.version} ${jib-maven-plugin.image} ${jib-maven-plugin.architecture} linux registry.dg.com/d4/foshan:latest latest ${version} bash /entrypoint.sh 8080 ALWAYS 0 USE_CURRENT_TIMESTAMP 1000 src/main/docker/jib /entrypoint.sh 755 org.apache.maven.plugins maven-war-plugin ${maven-war-plugin.version} default-war war package WEB-INF/**,META-INF/** false target/classes/static/ src/main/webapp WEB-INF/**
通过 --platform 参数指定
docker build --platform=linux/arm64 -t your_container_name:your_tag .
如果你想运行的官方镜像没有对应的系统架构,可以参考我的另一篇博文:
https://blog.csdn.net/Vampire69/article/details/124457204



