博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Docker镜像
阅读量:4882 次
发布时间:2019-06-11

本文共 3254 字,大约阅读时间需要 10 分钟。

四、Docker镜像(image)

  • docker采用分层构建机制,最底层为bootfs,次之为rootfs
    • bootfs: 用于系统引导的文件系统,包括BootLoader和kernel,容器启动完成后会被卸载以节约内存资源
    • rootfs: 位于bootfs之上,表现为docker容器的根文件系统,docker采用联合挂载,每一层都是只读的,在最上层有一个可写层
  • Aufs:高级多层统一文件系统,由Junjiro Okajima开发,早期使用
  • overlayfs & overlay2fs:至3.18版本开始被合并到Linux内核
# docker info |grep "Storage Driver"Storage Driver: overlay2
  • Docker Registry分类
Sponsor RegistryMirror RegistryVendor RegistryPrivate Registry
  • Docker Hub
Image Repositories  镜像仓库Automated Build  自动构建Webhooks  可以将GitHub中的dockerfile自动构建为镜像Organizations  组织GitHub and Bitbucket integration
  • docker image
build       Build an image from a Dockerfile  history     Show the history of an image  import      Import the contents from a tarball to create a filesystem image  inspect     Display detailed information on one or more images  load        Load an image from a tar archive or STDIN  ls          List images  prune       Remove unused images  pull        Pull an image or a repository from a registry  push        Push an image or a repository to a registry  rm          Remove one or more images  save        Save one or more images to a tar archive (streamed to STDOUT by default)  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  • docker image的制作(commit)
  1. 手工组织文件系统,打包成docker image
  2. 基于容器制作,在运行的容器上commit将可写层制作成image
  3. 基于Dockerfile手动build或者自动构建,Dockerfile基于Base image制作
# docker pull centos:centos7.5.1804# docker run --name centos -it centos:centos7.5.1804[root@xxxxxxxxxxx /]# yum install vim wget lftp bash-completion net-tools bind-utils telnet screen tree psmisc bc httpd -y# docker commit -p centos# docker image ls
484173886091 22 seconds ago 362MB# docker tag 484173886091 dongfeimg/mycentos:v0.1# docker image lsdongfeimg/mycentos v0.1 484173886091 5 minutes ago 362MB
# docker run --name mycentos -it dongfeimg/mycentos:v0.1[root@3c21ac1d0496 /]# mkdir -p /data/html/[root@3c21ac1d0496 /]# vim /var/www/html/index.html

Welcome Dongfei website.

# docker commit -a "Dongfei" -c 'CMD ["/usr/bin/systemctl","start","httpd"]' -p mycentos dongfeimg/mycentos:v0.2# docker run --name mycentos2 --privileged=true -d dongfeimg/mycentos:v0.2 /usr/sbin/init[root@docker ~]# docker exec -it 7cec67f74460 bash[root@7cec67f74460 /]# systemctl start httpd# docker inspect 7cec67f74460 |grep IPAddress"IPAddress": "172.17.0.4",# curl 172.17.0.4

Welcome Dongfei website.

  • docker push
# docker loginLogin with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.Username: dongfeimgPassword: ******WARNING! Your password will be stored unencrypted in /root/.docker/config.json.Configure a credential helper to remove this warning. Seehttps://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded# docker push dongfeimg/mycentos:v0.1# docker push dongfeimg/mycentos:v0.2
  • 镜像打包和导入
# docker save -o myimages.gz centos:centos7.5.1804 dongfeimg/mycentos:v0.1# docker load -i myimages.gz
  • 将docker images批量全部打包
# docker save $(docker images | grep -v REPOSITORY | awk 'BEGIN{OFS=":";ORS=" "}{print $1,$2}') -o images_name.gz

转载于:https://www.cnblogs.com/L-dongf/p/11028723.html

你可能感兴趣的文章
用户交互程序,格式化输出
查看>>
GNOME的发展与对比
查看>>
SPOJ PT07X Vertex Cover
查看>>
$ python-json模块的基本用法
查看>>
5.6.3.4 trim()方法
查看>>
Cookie、Session和自定义分页
查看>>
SQL演练
查看>>
React Antd中样式的修改
查看>>
Spring 应用外部属性文件 配置 context 错误
查看>>
导入lxml找不到etree,报ImportError:DLL load failed:找不到指定的程序
查看>>
面向对象一
查看>>
大象的崛起!Hadoop七年发展风雨录
查看>>
图片二值化
查看>>
数据库常用函数
查看>>
集合之TreeSet(含JDK1.8源码分析)
查看>>
C语言学习的记忆
查看>>
Lucene学习总结之三:Lucene的索引文件格式(1) 2014-06-25 14:15 1124人阅读 ...
查看>>
node-sass 报错的解决方法
查看>>
Python:GeoJson格式的多边形裁剪Tiff影像并计算栅格数值
查看>>
免费下载知网文献的方法 | sci-hub免费下载SCI论文方法
查看>>