jxp2002 发表于 2019-2-21 10:49:11

docker image 管理

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

[*]  启动docker容器后,把容器打包成镜像
docker commit容器名字   镜像名字
docker commit httpd-1 httpd-1-commit
[*]Docker file通过Docker file 可以通过自己的对镜像的的修改,并生成一个新的镜像.
  下面我们来做一个Dockerfile
  # cat Dockerfile
FROM httpd-1-commit
RUN touch /root/test
  # 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 目录下,否则会报 错误;
# 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}
  下一篇 dockerimage 私有仓库制作
http://blog.运维网.com/shyln/2130308



页: [1]
查看完整版本: docker image 管理