docker--shell和Exec格式

 2023-09-08 阅读 24 评论 0

摘要:shell格式 RUN apt-get install -y vim CMD echo "docker so easy" ENTRYPOINT echo "docker so easy" linuxshell脚本编程?Exec格式 RUN ["apt-get","install","-y","vim"] CMD ["echo","docker so easy"

shell格式

RUN apt-get install -y vim

CMD echo "docker so easy"

ENTRYPOINT echo "docker so easy"

 

linuxshell脚本编程?Exec格式

RUN ["apt-get","install","-y","vim"]

CMD ["echo","docker so easy"]

ENTRYPOINT ["echo","docker so easy"]

通过两个dockerfile来对比

 
[root@localhost test]# cat dockerfile1/Dockerfile 
from centos
ENV name Docker
ENTRYPOINT echo "$name so easy" [root@localhost test]# cat dockerfile2/Dockerfile from centos ENV name Docker ENTRYPOINT ["/bin/echo","$name so easy"]
[root@localhost test]# pwd
/test
[root@localhost test]# mkdir dockerfile1
[root@localhost test]# mkdir dockerfile2
[root@localhost test]# vim dockerfile1/Dockerfile
[root@localhost test]# cp dockerfile1/Dockerfile dockerfile2/
[root@localhost test]# vim dockerfile2/Dockerfile 
[root@localhost test]# cat dockerfile1/Dockerfile 
from centos
ENV name Docker
ENTRYPOINT echo "$name so easy"
[root@localhost test]# cat dockerfile2/Dockerfile 
from centos
ENV name Docker
ENTRYPOINT ["/bin/echo","$name so easy"]
[root@localhost test]# docker build -t bigni/centos_shell ./dockerfile1/
Sending build context to Docker daemon  2.048kB
Step 1/3 : from centos---> 9f38484d220f
Step 2/3 : ENV name Docker---> Running in 556fd0d58c0f
Removing intermediate container 556fd0d58c0f---> 43e2ff86b0c7
Step 3/3 : ENTRYPOINT echo "$name so easy"---> Running in d50a776a6a3a
Removing intermediate container d50a776a6a3a---> fc84f5de7f3b
Successfully built fc84f5de7f3b
Successfully tagged bigni/centos_shell:latest
[root@localhost test]# docker build -t bigni/centos_exec ./dockerfile2/
Sending build context to Docker daemon  2.048kB
Step 1/3 : from centos---> 9f38484d220f
Step 2/3 : ENV name Docker---> Using cache---> 43e2ff86b0c7
Step 3/3 : ENTRYPOINT ["/bin/echo","$name so easy"]---> Running in 4c226e9e7459
Removing intermediate container 4c226e9e7459---> 350ad6186f0b
Successfully built 350ad6186f0b
Successfully tagged bigni/centos_exec:latest
[root@localhost test]# docker image ls -a
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
bigni/centos_exec    latest              350ad6186f0b        10 seconds ago      202MB
bigni/centos_shell   latest              fc84f5de7f3b        41 seconds ago      202MB
<none>               <none>              43e2ff86b0c7        42 seconds ago      202MB
bigni/centos_vim     latest              f853f2a3f901        2 hours ago         362MB
<none>               <none>              3ec8199c2855        26 hours ago        861kB
bigni/test1          latest              f5620b92331c        26 hours ago        861kB
ubuntu               14.04               2c5e00d77a67        7 weeks ago         188MB
centos               latest              9f38484d220f        3 months ago        202MB
hello-world          latest              fce289e99eb9        6 months ago        1.84kB
[root@localhost test]# docker run bigni/centos_shell
Docker so easy
[root@localhost test]# docker run bigni/centos_exec
$name so easy
[root@localhost test]# vim dockerfile2/Dockerfile 
[root@localhost test]# cat dockerfile2/Dockerfile 
from centos
ENV name Docker
ENTRYPOINT ["/bin/bash","-c","/bin/echo $name so easy"]
[root@localhost test]# docker build -t bigni/centos_exec_new ./dockerfile2/
Sending build context to Docker daemon  2.048kB
Step 1/3 : from centos---> 9f38484d220f
Step 2/3 : ENV name Docker---> Using cache---> 43e2ff86b0c7
Step 3/3 : ENTRYPOINT ["/bin/bash","-c","/bin/echo $name so easy"]---> Running in c64527904495
Removing intermediate container c64527904495---> 6713eb2d0b46
Successfully built 6713eb2d0b46
Successfully tagged bigni/centos_exec_new:latest
[root@localhost test]# docker run bigni/centos_exec_new
Docker so easy
[root@localhost test]#

 

shell常用命令,转载于:https://www.cnblogs.com/laonicc/p/11147129.html

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/1/20274.html

上一篇:Oracle相关练习
下一篇:js执行顺序转

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息