为什么Docker会检查任何已安装的节点版本

zbq4xfa0  于 2022-12-03  发布在  Docker
关注(0)|答案(1)|浏览(155)

我已构建自定义前端映像

FROM node:16-alpine3.16

WORKDIR /usr/src/app

COPY . .

EXPOSE 4200

CMD ["npm", "run", "start"]

那我就用Docker作曲

docker compose up frontend-app --build

映像按预期运行和工作。
然后我用不带--build标志的docker compose运行它

docker compose up frontend-app

映像按预期运行和工作。
但当我禁用wi-fi(互联网),并再次运行之前的命令与--build标志,它显示我一个错误:

=> ERROR [internal] load metadata for docker.io/library/node:14.15.5-alpine3.10                                                                                                0.1s
------
 > [internal] load metadata for docker.io/library/node:14.15.5-alpine3.10:
------
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to do request: Head "https://registry-1.docker.io/v2/library/node/manifests/14.15.5-alpine3.10": Failed to lookup host: registry-1.docker.io

如果节点已经下载,甚至从Docker映像中单独拉出来,那么总是检查节点更新的意义是什么?
下一个命令显示此映像在本地已存在:

docker pull node:14.15.5-alpine3.10
14.15.5-alpine3.10: Pulling from library/node
b038bcb63e9c: Already exists 
2ad96160a6c4: Already exists 
694a34677dcf: Already exists 
253b9b23d1bc: Already exists 
Digest: sha256:fd87531f9bf187273c77ad3ddd5067110ef983f998fc2ea1b9932950df78bd8c
Status: Downloaded newer image for node:14.15.5-alpine3.10
docker.io/library/node:14.15.5-alpine3.10
t3psigkw

t3psigkw1#

使用--build您将再次构建映像,如果您已经有映像,为什么还要使用它?只使用docker-compose down和docker-compose-up

相关问题