码迷,mamicode.com
首页 > 其他好文 > 详细

docker image 管理

时间:2018-06-27 13:29:55      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:启动   end   lua   ima   send   软件版本   注意   from   参数   

通常我们在官方下载的镜像不能够切合的在我们生产环境中使用,比如缺包,和我们环境中所需要的环境软件版本不一致等,所以我们要自己制作镜像

制作镜像又两种方法:

  1. 启动docker容器后,把容器打包成镜像
    docker commit 容器名字 镜像名字
    docker commit httpd-1 httpd-1-commit

  2. Docker file 通过Docker file 可以通过自己的对镜像的的修改,并生成一个新的镜像.

下面我们来做一个Dockerfile

[root@docker Dockerfile]# cat Dockerfile
FROM httpd-1-commit
RUN touch /root/test

[root@docker Dockerfile]# docker build -t httpd-1-commit-with-touch .
Sending build context to Docker daemon 2.048 kB
Step 1/2 : FROM httpd-1-commit
---> d5e604e49f5c
Step 2/2 : RUN touch /root/test
---> Using cache
---> f8f075f7140d
Successfully built f8f075f7140d

使用方法:

docker build -t {image name } {Dockerfile path}
注意dockerfile 所在目录一定要在Dockerfile 目录下,否则会报 错误;
[root@docker home]# docker build -t with-touch-1 .
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/Dockerfile: no such file or directory

若不想使用image的缓存,则在加上--no-cache 的参数
docker build --no-cache -t {image name } {Dockerfile path}

下一篇 docker image 私有仓库制作
http://blog.51cto.com/shyln/2130308

docker image 管理

标签:启动   end   lua   ima   send   软件版本   注意   from   参数   

原文地址:http://blog.51cto.com/shyln/2133169

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!