我的主机( Ubuntu 20.04 )上有 2 个 Dockerfile。我正在运行 docker-ce 版本 Docker 版本 19.03.12,构建 48a66213fe 并启用了实验功能。我能够为 ARM 架构使用“docker buildx”构建它们中的每一个,并在我的嵌入式 Linux ARM 板上成功运行它们。
Dockerfile 1:
FROM python:3.8-slim-buster
COPY git /home/git
WORKDIR /home
RUN apt-get update -y && apt-get --no-install-recommends install build-essential pkg-config libzmq5 -y && \
cd git && python3 setup.py install && apt remove --purge build-essential pkg-config -y && \
apt auto-remove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
ADD publisher.py /home/publisher.py
Dockerfile 2:
FROM python:3.8-slim-buster
COPY git /home/git
WORKDIR /home
RUN apt-get update -y && apt-get --no-install-recommends install build-essential pkg-config libzmq5 -y && \
cd git && python3 setup.py install && apt remove --purge build-essential pkg-config -y && \
apt auto-remove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
ADD subscriber.py /home/subscriber.py
在主机上创建 ARM 兼容映像的构建过程:
docker buildx create --name builder || true
docker buildx use builder
docker buildx build --platform linux/arm/v7 -t "company-publisher:v1.3" . --load
docker save company-publisher:v1.3 > company-publisher-v1.3.tar
在 ARM 上加载图像:
docker load < ./company-publisher-v1.3.tar
订阅者的步骤相同。
由于图像基本相同,我想将发布者 Dockerfile 更改为以下内容:
FROM company-subscriber:v1.3
ADD publisher.py /home/publisher.py
Docker 图像显示它在本地:
REPOSITORY TAG IMAGE ID CREATED SIZE
company-subscriber v1.3 d2002fa18a8d 9 hours ago 121MB
但我得到如下所示的错误 - 它总是试图从 docker.io 中提取(它显然没有我试图继承的图像):
docker buildx build --platform linux/arm/v7 -t "company-publisher:v1.3" . --load
[+] Building 1.5s (5/6)
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 104B 0.0s
=> ERROR [internal] load metadata for docker.io/library/company-subscriber:v1.3 0.8s
=> [internal] load build context 0.0s
=> => transferring context: 34B 0.0s
=> ERROR [1/2] FROM docker.io/library/company-subscriber:v1.3 0.7s
=> => resolve docker.io/library/company-subscriber:v1.3 0.7s
------
> [internal] load metadata for docker.io/library/company-subscriber:v1.3:
------
------
> [1/2] FROM docker.io/library/company-subscriber:v1.3:
------
failed to solve: rpc error: code = Unknown desc = failed to load cache key: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
如何让 buildx 使用本地映像?谢谢。