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. 【学习总结】Eclipse常用快捷键

    相关博文 [JAVA]eclipse-Introduction

  2. Spring Boot 项目 Maven 配置

    在配置基于Maven的Spring Boot项目的过程中,打包运行出现了一系列错误. 比如: mvn 中没有主清单属性.java.lang.NoClassDefFoundError: org/spri ...

  3. rk3288 android5.1 修改时区

    /work/rk3288/firefly-rk3288_android5.1_git_20180126/device/rockchip/rk3288/rk3288_box/system.prop 修改 ...

  4. Swoole 简单学习(2)

    Swoole 简单学习(2) swoole之tcp服务器: //创建tcp服务器new swoole_server(string $host,int $port,int $mode=SWOOLE_PR ...

  5. 【串线篇】Mybatis缓存之二级缓存

    1.应用 二级缓存:namespace级别的缓存:SqlSession关闭或者提交以后有效 一级缓存:SqlSession关闭或者提交以后,一级缓存的数据会放在二级缓存中: 二级缓存的使用:mybat ...

  6. Vue中 let 关键字

    let es6新增了let命令,用来声明变量.它的用法类似于var,但是所声明的变量,只在let命令所在的代码块内有效. 不存在变量提升 var命令会发生”变量提升“现象,即变量可以在声明之前使用,值 ...

  7. poj 2186: Popular Cows(tarjan基础题)

    题目链接 tarjan参考博客 题意:求在图上可以被所有点到达的点的数量. 首先通过tarjan缩点,将所有内部两两可达的子图缩为一点,新图即为一个有向无环图(即DAG). 在这个DAG上,若存在不止 ...

  8. SQL Server 2008 R2 数据库备份文件.bak如何挂载到【阿里云&#183;独立虚拟主机数据库】上

    1.前言 8月份刚刚开始,公司[工作流]挂了,实体服务器会自动重启,数据库死活起不来,这可是计算工资提成的事儿,不能马虎! 在实体服务器中,找到了OA页面源码与数据库的.MDF 与 .LDF 等文件. ...

  9. 4412 linux延时和时间

    基本知识 • linux中延时函数很简单,却经常用到• 在操作系统中和单片机处理延时方式就完全不一样了,不可能是使用for循环浪费系统资源.而是有专门的接口函数• linux系统编程中常用的延时函数: ...

  10. 【UNR #2】黎明前的巧克力 解题报告

    [UNR #2]黎明前的巧克力 首先可以发现,等价于求 xor 和为 \(0\) 的集合个数,每个集合的划分方案数为 \(2^{|S|}\) ,其中 \(|S|\) 为集合的大小 然后可以得到一个朴素 ...