泊坞窗多阶段构建授权问题-但是在拉动时没有身份验证问题

时间:2019-01-15 21:15:17

标签: docker docker-build

我遇到一个奇怪的问题,无法追踪。

从干净的开始-计算机上没有现有的图像

我的docker文件如下:

# Pulll down the config container
FROM mdc2-b-registry.xxx.yyy.org:9080/configs as configs
FROM openjdk:8-alpine
RUN mkdir /logs
RUN chmod 777 /logs
COPY --from=configs /configs /configs

如果我尝试以下任何构建命令:

docker build --pull  -t test .
docker build -t test .
docker build --no-cache --pull --disable-content-trust --force-rm -t test .

我收到以下错误:

Sending build context to Docker daemon  17.93MB
Step 1/12 : FROM "mdc2-b-registry.xxx.yyy.org:9080/configs" as configs
unauthorized: access to the requested resource is not authorized

现在,如果我先拉动

docker pull mdc2-b-registry.xxx.yyy.org:9080/configs

Using default tag: latest
latest: Pulling from configs
cd784148e348: Already exists
8bd27e759c62: Pull complete
0d55a756f4a7: Pull complete
Digest: sha256:fe4b11852e65d4a540d3cd039f5df09a02d4b598657ef2ff8f3d4527336aa7da
Status: Downloaded newer image for mdc2-b-registry.xxx.yyy.org:9080/configs:latest

然后:

docker build -t test .

Sending build context to Docker daemon  17.93MB
Step 1/5 : FROM mdc2-b-registry.xxx.yyy.org:9080/configs as configs
 ---> bf768712856e
Step 2/5 : FROM openjdk:8-alpine
 ---> 54ae553cb104
Step 3/5 : RUN mkdir /logs
 ---> Using cache
 ---> c204676b3ed8
Step 4/5 : RUN chmod 777 /logs
 ---> Using cache
 ---> 11dd17202404
Step 5/5 : COPY --from=configs /configs /configs
 ---> c5643f9a43bb
Successfully built c5643f9a43bb
Successfully tagged test:latest

我要在 ci 任务中执行此操作-因此我从理论上讲可以先执行拉取操作-但是我对为什么auth错误处于多阶段感到困惑,即使它上面有--pull命令。

这是预期的行为吗,我是在做错什么还是错误?

(我们的注册表确实需要登录-但您只需登录一次即可,它会存储凭据)

0 个答案:

没有答案