您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
27_尚硅谷_Docker_DockerFile案例-ONBUILD命令案例
发布时间:2022-11-13 19:26:39编辑:雪饮阅读()
onbuild是在某个镜像被其它镜像from后然后build时候触发的。
构建父类DockerFile:
[root@localhost mydocker]# cat DockerFile5
from centos:centos7
run yum install -y curl
entrypoint ["curl","-i","www.baidu.com"]
onbuild run echo "my onbuild is runing"
父类镜像构建
docker build -f /root/mydocker/DockerFile5 -t centos75 .
构建子类DockerFile:
[root@localhost mydocker]# cat DockerFile6
from centos75
run yum install -y curl
entrypoint ["curl","-i","www.baidu.com"]
构建子类镜像
[root@localhost mydocker]# docker build -f /root/mydocker/DockerFile6 -t centos76 .
Sending build context to Docker daemon 7.168kB
Step 1/3 : from centos75
# Executing 1 build trigger
---> Running in abed4767248d
my onbuild is runing
Removing intermediate container abed4767248d
---> 8f11e99ff055
Step 2/3 : run yum install -y curl
---> Running in 4893fcf71bd7
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* extras: mirrors.163.com
* updates: mirrors.163.com
Package curl-7.29.0-59.el7_9.1.x86_64 already installed and latest version
Nothing to do
Removing intermediate container 4893fcf71bd7
---> b1b3f0a7bdee
Step 3/3 : entrypoint ["curl","-i","www.baidu.com"]
---> Running in df32eee13d0f
Removing intermediate container df32eee13d0f
---> decce64298b6
Successfully built decce64298b6
Successfully tagged centos76:latest
关键字词:Docker,DockerFile,案例,ONBUILD,命令