使用 docker 创建自己的镜像
创建自己的镜像 image
- 创建一个 Dockerfile 文件
- 根据 Dockerfile 来 Build 镜像
$ docker build
-t
docker
-whale
.
Sending build context to Docker daemon 2.048 kB
...snip...
Removing intermediate container cb53c9d09f3b
Successfully built c2c3152907b5
Docker检查确认所有build所需都齐了,输出如下消息:
Sending build context to Docker daemon 2.048 kB
Docker 检查
whalesay
image 是否存在,不存在则从Docker Hub上pull下来。Step 1 : FROM docker/whalesay:latest---> 6b362a9f73eb
在每一步结束,都会有一个ID被打印出来。这个ID是每一步创建出的 Layer 的ID。 Dockerfile 中每一行命令都和 image 中的一个 Layer 相关。你自己的ID会显示的不一样。
Docker 创建一个临时容器 container 来运行
whalesay
镜像image。在这个临时容器中,Docker 运行 Dockerfile中的下一条命令, 即RUN
命令。这会安装fortune
。这里会有很多输出,就和在 Ubuntu 中创建出来的消息一样。Step 2 : RUN apt-get -y update && apt-get install -y fortunes---> Running in 05d4eda04526 Ign http://archive.ubuntu.com trusty InRelease Get:1 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB] Get:2 http://archive.ubuntu.com trusty-security InRelease [65.9 kB] Hit http://archive.ubuntu.com trusty Release.gpg Hit http://archive.ubuntu.com trusty Release Get:3 http://archive.ubuntu.com trusty-updates/main Sources [480 kB] Get:4 http://archive.ubuntu.com trusty-updates/restricted Sources [5921 B] Get:5 http://archive.ubuntu.com trusty-updates/universe Sources [214 kB] Get:6 http://archive.ubuntu.com trusty-updates/main amd64 Packages [1160 kB] Get:7 http://archive.ubuntu.com trusty-updates/restricted amd64 Packages [20.4 kB] Get:8 http://archive.ubuntu.com trusty-updates/universe amd64 Packages [505 kB] Get:9 http://archive.ubuntu.com trusty-security/main Sources [157 kB] Get:10 http://archive.ubuntu.com trusty-security/restricted Sources [4621 B] Get:11 http://archive.ubuntu.com trusty-security/universe Sources [54.5 kB] Get:12 http://archive.ubuntu.com trusty-security/main amd64 Packages [700 kB] Get:13 http://archive.ubuntu.com trusty-security/restricted amd64 Packages [17.0 kB] Get:14 http://archive.ubuntu.com trusty-security/universe amd64 Packages [191 kB] Hit http://archive.ubuntu.com trusty/main Sources Hit http://archive.ubuntu.com trusty/restricted Sources Hit http://archive.ubuntu.com trusty/universe Sources Hit http://archive.ubuntu.com trusty/main amd64 Packages Hit http://archive.ubuntu.com trusty/restricted amd64 Packages Hit http://archive.ubuntu.com trusty/universe amd64 Packages Fetched 3640 kB in 11s (329 kB/s) Reading package lists... Reading package lists... Building dependency tree... Reading state information... The following extra packages will be installed:fortune-mod fortunes-min librecode0 Suggested packages:x11-utils bsdmainutils The following NEW packages will be installed:fortune-mod fortunes fortunes-min librecode0 0 upgraded, 4 newly installed, 0 to remove and 92 not upgraded. Need to get 1961 kB of archives. After this operation, 4817 kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main librecode0 amd64 3.6-21 [771 kB] Get:2 http://archive.ubuntu.com/ubuntu/ trusty/universe fortune-mod amd64 1:1.99.1-7 [39.5 kB] Get:3 http://archive.ubuntu.com/ubuntu/ trusty/universe fortunes-min all 1:1.99.1-7 [61.8 kB] Get:4 http://archive.ubuntu.com/ubuntu/ trusty/universe fortunes all 1:1.99.1-7 [1089 kB] debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.) debconf: falling back to frontend: Readline debconf: unable to initialize frontend: Readline debconf: (This frontend requires a controlling tty.) debconf: falling back to frontend: Teletype dpkg-preconfigure: unable to re-open stdin: Fetched 1961 kB in 19s (101 kB/s) Selecting previously unselected package librecode0:amd64. (Reading database ... 13116 files and directories currently installed.) Preparing to unpack .../librecode0_3.6-21_amd64.deb ... Unpacking librecode0:amd64 (3.6-21) ... Selecting previously unselected package fortune-mod. Preparing to unpack .../fortune-mod_1%3a1.99.1-7_amd64.deb ... Unpacking fortune-mod (1:1.99.1-7) ... Selecting previously unselected package fortunes-min. Preparing to unpack .../fortunes-min_1%3a1.99.1-7_all.deb ... Unpacking fortunes-min (1:1.99.1-7) ... Selecting previously unselected package fortunes. Preparing to unpack .../fortunes_1%3a1.99.1-7_all.deb ... Unpacking fortunes (1:1.99.1-7) ... Setting up librecode0:amd64 (3.6-21) ... Setting up fortune-mod (1:1.99.1-7) ... Setting up fortunes-min (1:1.99.1-7) ... Setting up fortunes (1:1.99.1-7) ... Processing triggers for libc-bin (2.19-0ubuntu6.6) ...---> dfaf993d4a2e Removing intermediate container 05d4eda04526
RUN
结束,有一个 layer 会被创建,并且之前创建的临时容器 container 也被去除了。一个新的临时容器 container 被创建出来,Docker 为CMD命令添加一个 Layer,然后在移除该容器 congtainer
Step 3 : CMD /usr/games/fortune -a | cowsay---> Running in a8e6faa88df3---> 7d9495d03763 Removing intermediate container a8e6faa88df3 Successfully built 7d9495d03763
到这里,我们就创建了一个自己的镜像 image,名叫 docker-whale
.
接下来直接运行 docker run docker-whale
转载于:https://www.cnblogs.com/zhxshseu/p/1514f50b8b910c50a119cf2c38553e64.html
使用 docker 创建自己的镜像相关推荐
- Docker创建自己的镜像库
Docker容器配置 1.新建一个文件夹 文件夹列表 2.定义一个容器 Dockerfile Dockerfile定义您的容器内环境中发生了什么.访问网络接口和磁盘驱动器等资源是在此环境中虚拟化的,与 ...
- Linux下使用docker创建自己的镜像并提交到docker hub
创建镜像,是在有基础镜像的前提下,开发者需要定义属于自己的独特的开发环境,比如在centos7上安装python3的完整环境,然后形成一个centos7+python3的镜像,这样,在下次使用,就不用 ...
- Docker创建springboot项目镜像pom及Dockerfile配置文件
pom文件添加插件 <build><plugins><plugin><groupId>org.springframework.boot</grou ...
- Docker(二):Docker常用命令之镜像的创建:Dockerfile 与 commit
相关阅读: Docker(一):Docker的安装与常用命令 Docker(二):Docker常用命令之镜像的创建:Dockerfile 与 commit Docker(三):Docker镜像导入与导 ...
- docker学习笔记(二)创建自己的镜像
目录 image与container的可读写性 创建自己的镜像 dockerfile语法 创建自己的springboot项目image(Dockerfile方式) 推送镜像到镜像仓库(阿里云) 通过C ...
- Docker 创建镜像
创建镜像有很多方法,用户可以从 Docker Hub 获取已有镜像并更新,也可以利用本地文件系统创建一个. 修改已有镜像 先使用下载的镜像启动容器. $ sudo docker run -t -i t ...
- Docker创建一个镜像
创建 Dockerfile 文件.index.html测试页面 [root@localhos ~]# vi DockerfileFROM nginx:1.17.6 #基于 nginx 1.17,在bu ...
- Docker build创建指定容器镜像
Docker build: Build an image from a Dockerfile. 按照Dockerfile文件所定义内容创建临时性容器,把Docker中所定义的每行命令在临时容器中执行, ...
- Docker学习之路04:创建定制Nginx镜像
Docker学习之路04:创建定制Nginx镜像 Docker学习路线传送门: Docker学习之路01:Docker的安装 Docker学习之路02:阿里云镜像加速器 Docker学习之路03:Do ...
最新文章
- 【linux】Valgrind工具集详解(四):抑制错误
- 互联网公装企业“inDeco领筑智造”完成A+B轮近1.1亿元融资
- 18-python基础7-闭包函数和装饰器
- android键盘映射(转)-- good 1,android UI
- solr入门之參考淘宝搜索提示功能优化拼音加汉字搜索功能
- c#参数修饰符-params
- laravel 下载报错:Unable to guess the mime type as no guessers are available
- docker 解决php 502,Docker里两个php容器一个正常访问,一个出现502 Bad Gateway nginx/1.17.8。...
- 事态升级是什么意思_俗语“头不顶桑脚不踩槐;生不睡柳死不睡杨”啥意思 有道理吗...
- 谁将赢得 5G 比赛?| 畅言
- 洛谷P1411 砝码称重
- 如何向Mac Dictionary App添加其他语言
- 用C语言开发最简单的小游戏(弹跳小球)
- java课程 教 学小结_Java私塾中级课程学习感受和小结3
- CSR3026开发问题总结-1
- 浩海技术激活工具可激活Windows10系统和office
- 八大数据分析模型之——用户模型(一)
- 从.snk文件导出密钥
- 微软360度——成功与成长
- 媒体应用视频超分AI神器!360P视频一键转换HD
热门文章
- ROS中阶笔记(三):机器人仿真—ArbotiX+rviz功能仿真
- 用python实现语音的传输功能_用Python+WechatPCAPI实现微信消息防撤回
- python代码运行到一半终止_Python 程序运行时卡住,既不报错,也不停止,也不动,是什么原因?...
- python编译exe运行慢_Python运行速度慢你知道这是为什么吗?
- 学习机软件测试,IBM P630 POWER4 AIX小型机适合软件测试及学习机
- hfss仿真时间过长怎么解决_一文详解相控阵天线仿真技术
- sql server查询某一字段不重复的数据_初识数据库
- ios view添加上边框_ios – UIView的圆顶角,并添加边框
- linux mii,Linux mii-tool 命令用法详解-Linux命令大全(手册)
- html网页无法刷新,网页不能自动刷新怎么办