Mac OS Docker容器构建Issues

sudo docker buildx build --platform linux/amd64 -t meseum_geo_api_app .

DOCKER_BUILDKIT=0 docker-compose up 

Issue

  • Apple M2芯片如何构建docker Linux镜像?

docker - "exec format error" when running containers build with Apple M1 Chip (ARM based systems) - Stack Overflow

  • 运行docker build命令出现ERROR: failed to solve: knowledge_graph_component:latest: failed to resolve source metadata for docker.io/library/knowledge_graph_component:latest: failed to authorize: failed to fetch anonymous token

    命令行登录docker后该问题不再出现

    docker login
    
  • 本地存在基础镜像A,但基于镜像A构造另一个镜像时,docker尝试从远程拉取(不存在)并失败。

    失败命令:

     sudo docker build -t knowledge_graph_component_backend_app-sso:latest .
    

    失败报错信息:

    成功命令:

     sudo docker build --platform=linux/amd64 -t knowledge_graph_component_backend_app-sso:latest .
    

失败原因:基础镜像是在AMD架构的机器上构建的(docker build默认会构建本机架构的镜像)。通过docker desktop可以查看镜像的平台架构是否与本机有冲突:

参考链接

https://stackoverflow.com/questions/56512769/unable-to-find-docker-image-locally

CoolCats
CoolCats
理学学士

我的研究兴趣是时空数据分析、知识图谱、自然语言处理与服务端开发