执行docker build 出错

[root@zheng ~]# docker build -f /root/dockerfile/ONBUILD-son -t onbuild-son:1.0 .
Sending build context to Docker daemon   85.5kB
Step 1/2 : FROM onbuild-father
pull access denied for onbuild-father, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

dockerfile文件
[root@zheng ~]# cat dockerfile/ONBUILD-son
FROM onbuild-father
ENTRYPOINT [ “ls”]

根据错误提示是:repository不存在或者需要运行docker login登录,但是根据官方文档:在docker hub中搜索或者拉去images时并不需要账户并且登录

我们把子镜像的dockerfile文件加上版本号

[root@zheng ~]# vi  dockerfile/ONBUILD-son 
FROM onbuild-father:1.0

ENTRYPOINT [ "ls"]

再重新build一下

[root@zheng ~]# docker build -f /root/dockerfile/ONBUILD-son -t onbuild-son:1.0 .
Sending build context to Docker daemon   85.5kB
Step 1/2 : FROM onbuild-father:1.0

# Executing 3 build triggers      ##这里就显示之前的三个onbuild指令了
 ---> Running in 155e97707098
father images onbuild --------------- sucessful
Removing intermediate container 155e97707098
 ---> Running in 71dbe5ca5f90
Removing intermediate container 71dbe5ca5f90
 ---> Running in ba6312afb1e7
Removing intermediate container ba6312afb1e7
 ---> 3c12ab2b9009
Step 2/2 : ENTRYPOINT [ "ls"]
 ---> Running in c055960e8aad
Removing intermediate container c055960e8aad
 ---> ab484814bfdc
Successfully built ab484814bfdc
Successfully tagged onbuild-son:1.0

成功解决

Logo

鸿蒙生态一站式服务平台。

更多推荐