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格式的更多相关文章

  1. Shell中取时间格式方法

    Shell中取时间格式方法2007-09-13 15:35常用date的显示格式: date +%F //2007-03-06date +%Y%m%d//20070306 date +%T //23: ...

  2. Linux下Shell日期的格式,你知道几种?

    Linux下Shell日期的格式,你知道几种? 不管是哪种语言,日期/时间都是一个非常重要的值.比如我们保存日志的时候,往往是某个前缀再加上当前时间,这样日志文件名称就可以做到唯一. 在Shell环境 ...

  3. Linux:可执行程序的Shell传参格式规范

    1. Linux下可执行程序的Shell传参格式规范 Linux下的可执行程序在运行时经常需要传一些参数,而这些参数是有规范的.包括我们自己写的在Linux系统下运行的Shell脚本.Python脚本 ...

  4. shell中exec解析(转)

    参考:<linux命令.编辑器与shell编程> <unix环境高级编程> exec和source都属于bash内部命令(builtins commands),在bash下输入 ...

  5. shell中exec解析

    参考:<linux命令.编辑器与shell编程> <unix环境高级编程> exec和source都属于bash内部命令(builtins commands),在bash下输入 ...

  6. shell编程--基本格式,基本语法,运算符,expr,(()),$[]

    02/shell编程 Shell是用户与内核进行交互操作的一种接口,目前最流行的Shell称为bash Shell Shell也是一门编程语言."."号执行脚本时,会让脚本在调用者 ...

  7. 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 ...

  8. shell的exec命令

    工作中遇到运维人员挂supervisor的时候建议启动使用命令control.sh start, 并且在control.sh 里面启动命令: exec -c ./bin/xxx -f config/x ...

  9. shell中exec命令

    1.find中的-exec参数 在当前目录下(包含子目录),查找所有txt文件并找出含有字符串"bin"的行 find ./ -name "*.txt" -ex ...

随机推荐

  1. bounds与frame的区别及setBounds的使用

    转自http://www.cocoachina.com/ios/20140925/9755.html 在iOS开发中经常遇到两个词Frame和bounds,本文主要阐述Frame和bound的区别,尤 ...

  2. 【记录】elastiasearch 6.4.3 版本 SearchRequestBuilder字段排序,BoolQueryBuilder

    参考地址: 1:https://www.cnblogs.com/shoutn/p/8027960.html 2:https://www.jianshu.com/p/8402eb930ae7 3:htt ...

  3. linux网络子系统调优

  4. go语言学习之从例子开始

    [目录] go语言从例子开始之Example1.helloworld go语言从例子开始之Example2.类型 go语言从例子开始之Example3.变量 go语言从例子开始之Example4.常量 ...

  5. Mongodb使用shell实现与javascript的动态交互

    关于利用mongodb的shell执行脚本,这点在以前的文章中有点遗漏:现在在此篇博客中做个补充: 一.在命令行中传入脚本文件 定义一个javasciprt文件,名称为:script1.js,内容如下 ...

  6. 使用jstack排查线程问题

    以一个例子来演示排查服务器cpu占用率过高的问题. 准备 将下面的代码文件上传到服务器上,然后使用javac编译,并使用java命令将程序跑起来. public class JStackCase { ...

  7. 人生苦短_我用Python_logging日志操作_011

    话不多说,开搞,基础是先使用自带loggin模块,level为warning以上, 进一步是自定义logger,level可自定义 #!/usr/bin/env python # -*- coding ...

  8. 25-Node.js学习笔记-express-app.locals对象

    app.locals对象 将变量设置到app.locals对象下面,这个数据在所有的模板中都可以获取到 app.locals.users=[{ name:'柠檬不酸', age:20 },{ name ...

  9. 用Redis进行实时数据排名

    1先生成一个Redis对象 2实例化一个对象.zscore有序集合中进行排序 3 Redis Zscore命令返回有序集合中,成员的分数值.如果成员元素不是有序集合 key的成员,则key不存在,返回 ...

  10. JS中正则表达式

    正则表达式用于对字符串模式匹配及检索替换,是对字符串执行模式匹配的强大工具.简单来说正则表达式就是处理字符串的,我们可以用它来处理一些复杂的字符串. 1.创建方式 pattern(模式):描述了表达式 ...