docker--shell和Exec格式
shell格式
RUN apt-get install -y vim
CMD echo "docker so easy"
ENTRYPOINT echo "docker so easy"
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 .048kB
Step / : from centos
---> 9f38484d220f
Step / : ENV name Docker
---> Running in 556fd0d58c0f
Removing intermediate container 556fd0d58c0f
---> 43e2ff86b0c7
Step / : 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 .048kB
Step / : from centos
---> 9f38484d220f
Step / : ENV name Docker
---> Using cache
---> 43e2ff86b0c7
Step / : 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 seconds ago 202MB
bigni/centos_shell latest fc84f5de7f3b seconds ago 202MB
<none> <none> 43e2ff86b0c7 seconds ago 202MB
bigni/centos_vim latest f853f2a3f901 hours ago 362MB
<none> <none> 3ec8199c2855 hours ago 861kB
bigni/test1 latest f5620b92331c hours ago 861kB
ubuntu 14.04 2c5e00d77a67 weeks ago 188MB
centos latest 9f38484d220f months ago 202MB
hello-world latest fce289e99eb9 months ago .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 .048kB
Step / : from centos
---> 9f38484d220f
Step / : ENV name Docker
---> Using cache
---> 43e2ff86b0c7
Step / : 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]#
docker--shell和Exec格式的更多相关文章
- Shell中取时间格式方法
Shell中取时间格式方法2007-09-13 15:35常用date的显示格式: date +%F //2007-03-06date +%Y%m%d//20070306 date +%T //23: ...
- Linux下Shell日期的格式,你知道几种?
Linux下Shell日期的格式,你知道几种? 不管是哪种语言,日期/时间都是一个非常重要的值.比如我们保存日志的时候,往往是某个前缀再加上当前时间,这样日志文件名称就可以做到唯一. 在Shell环境 ...
- Linux:可执行程序的Shell传参格式规范
1. Linux下可执行程序的Shell传参格式规范 Linux下的可执行程序在运行时经常需要传一些参数,而这些参数是有规范的.包括我们自己写的在Linux系统下运行的Shell脚本.Python脚本 ...
- shell中exec解析(转)
参考:<linux命令.编辑器与shell编程> <unix环境高级编程> exec和source都属于bash内部命令(builtins commands),在bash下输入 ...
- shell中exec解析
参考:<linux命令.编辑器与shell编程> <unix环境高级编程> exec和source都属于bash内部命令(builtins commands),在bash下输入 ...
- shell编程--基本格式,基本语法,运算符,expr,(()),$[]
02/shell编程 Shell是用户与内核进行交互操作的一种接口,目前最流行的Shell称为bash Shell Shell也是一门编程语言."."号执行脚本时,会让脚本在调用者 ...
- syntax error near unexpected token `do(写的shell脚本出现格式问题)--->1.问题2.展示信息3.解决方案
1问题:Linux和windows下的回车换行符不兼容的问题 [root@node-01 script]# sh start_zk.sh art_zk.sh: line 3: syntax error ...
- shell的exec命令
工作中遇到运维人员挂supervisor的时候建议启动使用命令control.sh start, 并且在control.sh 里面启动命令: exec -c ./bin/xxx -f config/x ...
- shell中exec命令
1.find中的-exec参数 在当前目录下(包含子目录),查找所有txt文件并找出含有字符串"bin"的行 find ./ -name "*.txt" -ex ...
随机推荐
- linux系统使用和优化的原则
- [算法学习]开始leetcode之旅
在此记录一下用javascript刷leetcode的过程,每天都要坚持! 1.Two Sum Given an array of integers, find two numbers such th ...
- MySQL MHA+Keepalived
一.MHA的简单介绍MHA是由perl语言编写的,用外挂脚本的方式实现mysql主从复制的高可用性.MHA可以自动检测mysql是否宕机,如果宕机,在10-30s内完成new master的选举,应用 ...
- HTML5知识点总结(一)
最近在复习前端的基础知识,在这里做一个总结,这是HTML5篇. 新特性 取消了过时的显示效果标记<font></font>和<center></center& ...
- TLSv网络安全标准,会话加密协议展望未来
本文是关于TLSv1.3采用的三部分系列的第三部分也是最后一部分.它解决了网络加密和监控的选项,包括备用会话加密协议. 通过TLSv1.3的批准,并在IETF出版物队列中,是时候考虑部署选项和障碍,并 ...
- 警惕黑客利用新方法绕过Office安全链接
东方联盟黑客安全研究人员透露,一些黑客已经发现绕过MicrosoftOffice365的安全功能,该功能最初旨在保护用户免受恶意软件和网络钓鱼攻击. 被称为安全链接的功能已被包含在Office365软 ...
- HTML基础知识笔记摘要
HTML互联网三大基石:1.HTML:显示数据2.HTTP:传输数据 http传输协议3.URL:定位数据协议://ip地址或主机名:端口/网络中的内容... HTML(hyper text make ...
- 详解如何定义SQL Server外关键字约束
SQL Server外关键字约束定义了表之间的关系.当一个表中的一个列或多个列的组合和其它表中的主关键字定义相同时,就可以将这些列或列的组合定义为外关键字,并设定它适合哪个表中哪些列相关联.这样,当在 ...
- npm和webpack安装以及相关信息
一.npm初始化 在项目文件夹下执行npm init,根据提示回车或者填写信息.结果是生成packge.json文件. 根据json文件npm install会安装依赖,项目会看到有一个node_mo ...
- JPush极光推送Java服务器端实例
import cn.jpush.api.JPushClient; import cn.jpush.api.common.resp.APIConnectionException; import cn.j ...