【Docker】从零开始:8.Docker命令:Commit提交命令

【Docker】从零开始:8.Docker命令:Commit命令

  • 基本概念
    • 镜像
    • 镜像分层
      • 什么是镜像分层
      • 为什么 Docker 镜像要采用这种分层结构
  • 本章要点
  • commit 命令
    • 命令格式
    • docker commit 操作参数
    • 实例演示
      • 1.下载一个新的ubuntu镜像
      • 2.运行容器
      • 3.查看并安装vim
      • 4.退出容器
      • 5提交自己的镜像
      • 对比
    • 总结

了解commit命令之前我们先了解下涉及的相关知识
为什么这里又说镜像,因为之前了解的只是个大概,现在涉及镜像的原理

基本概念

镜像

  • 是一种轻量级、可执行的独立软件包,它包含运行某个软件所需的所有内容,我们把应用程序和配置依赖打包好形成一个可交付的运行环境(包括代码、运行时需要的库、环境变量和配置文件等),这个打包好的运行环境就是image镜像文件。
  • 只有通过这个镜像文件才能生成Docker容器实例(类似Java中new出来一个对象)。

镜像分层

什么是镜像分层

  • “镜像是有分层的”
    • 如图所示:
      在这里插入图片描述
  • 镜像的使用的文件技术是UnionFS
    • UnionFS(联合文件系统)
      • UnionFS(联合文件系统):Union文件系统(UnionFS)是一种分层、轻量级并且高性能的文件系统,它支持对文件系统的修改作为一次提交来一层层的叠加,同时可以将不同目录挂载到同一个虚拟文件系统下(unite several directories into a single virtual filesystem)。Union 文件系统是 Docker 镜像的基础。镜像可以通过分层来进行继承,基于基础镜像(没有父镜像),可以制作各种具体的应用镜像。
      • 特性:一次同时加载多个文件系统,但从外面看起来,只能看到一个文件系统,联合加载会把各层文件系统叠加起来,这样最终的文件系统会包含所有底层的文件和目录
  • Docker镜像加载原理:
    • Docker的镜像实际上由一层一层的文件系统组成,这种层级的文件系统UnionFS。
    • Bootfs(boot file system)主要包含bootloader和kernel, bootloader主要是引导加载kernel, Linux刚启动时会加载bootfs文件系统,在Docker镜像的最底层是引导文件系统bootfs。这一层与我们典型的Linux/Unix系统是一样的,包含boot加载器和内核。当boot加载完成之后整个内核就都在内存中了,此时内存的使用权已由bootfs转交给内核,此时系统也会卸载Bootfs。
    • rootfs (root file system) ,在bootfs之上。包含的就是典型 Linux 系统中的 /dev, /proc, /bin, /etc 等标准目录和文件。rootfs就是各种不同的操作系统发行版,比如Ubuntu,Centos等等。

在这里插入图片描述

对于一个精简的OS,rootfs可以很小,只需要包括最基本的命令、工具和程序库就可以了,因为底层直接用Host的kernel,自己只需要提供 rootfs 就行了。由此可见对于不同的linux发行版, bootfs基本是一致的, rootfs会有差别, 因此不同的发行版可以公用bootfs。

为什么 Docker 镜像要采用这种分层结构

  • 比如说有多个镜像都从相同的 base 镜像构建而来,那么 Docker Host 只需在磁盘上保存一份 base 镜像;
    同时内存中也只需加载一份 base 镜像,就可以为所有容器服务了。而且镜像的每一层都可以被共享。

本章要点

  • Docker镜像层都是只读的,容器层是可写的。
  • 当容器启动时,一个新的可写层被加载到镜像的顶部。这一层通常被称作“容器层”,“容器层”之下的都叫“镜像层”。
  • 所有对容器的改动 - 无论添加、删除、还是修改文件都只会发生在容器层中。只有容器层是可写的,容器层下面的所有镜像层都是只读的。
    在这里插入图片描述

commit 命令

  • docker commit 命令用于根据 Docker容器 的更改创建一个新的 Dokcer镜像。该命令后面的 CONTAINER 可以是容器Id,或者是容器名。

命令格式

docker commit -m="[提交的描述信息]" -a="[作者]" [容器ID] [新的镜像名称]:[新的镜像标签]

docker commit 操作参数

参数描述
-a, --author string作者。
-c, --change list应用 dockerfile 指令来创建图像。
-m, --messagestring
-p, --pause提交期间暂停容器(默认为true)。

实例演示

1.下载一个新的ubuntu镜像

[root@docker ~]# docker search ubuntu
NAME                             DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
ubuntu                           Ubuntu is a Debian-based Linux operating sys…   16622     [OK]       
websphere-liberty                WebSphere Liberty multi-architecture images …   297       [OK]       
open-liberty                     Open Liberty multi-architecture images based…   62        [OK]       
neurodebian                      NeuroDebian provides neuroscience research s…   105       [OK]       
ubuntu-debootstrap               DEPRECATED; use "ubuntu" instead                 52        [OK]       
ubuntu-upstart                   DEPRECATED, as is Upstart (find other proces…   115       [OK]       
ubuntu/nginx                     Nginx, a high-performance reverse proxy & we…   102                  
ubuntu/squid                     Squid is a caching proxy for the Web. Long-t…   70                   
ubuntu/cortex                    Cortex provides storage for Prometheus. Long…   4                    
ubuntu/apache2                   Apache, a secure & extensible open-source HT…   65                   
ubuntu/prometheus                Prometheus is a systems and service monitori…   51                   
ubuntu/kafka                     Apache Kafka, a distributed event streaming …   37                   
ubuntu/bind9                     BIND 9 is a very flexible, full-featured DNS…   64                   
ubuntu/mysql                     MySQL open source fast, stable, multi-thread…   54                   
ubuntu/zookeeper                 ZooKeeper maintains configuration informatio…   12                   
ubuntu/postgres                  PostgreSQL is an open source object-relation…   31                   
ubuntu/redis                     Redis, an open source key-value store. Long-…   21                   
ubuntu/jre                       Distroless Java runtime based on Ubuntu. Lon…   9                    
ubuntu/grafana                   Grafana, a feature rich metrics dashboard &9                    
ubuntu/dotnet-aspnet             Chiselled Ubuntu runtime image for ASP.NET a…   13                   
ubuntu/memcached                 Memcached, in-memory keyvalue store for smal…   5                    
ubuntu/dotnet-deps               Chiselled Ubuntu for self-contained .NET & A…   11                   
ubuntu/prometheus-alertmanager   Alertmanager handles client alerts from Prom…   9                    
ubuntu/dotnet-runtime            Chiselled Ubuntu runtime image for .NET apps…   13                   
ubuntu/cassandra                 Cassandra, an open source NoSQL distributed …   2                    
[root@docker ~]# docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
7b1a6ab2e44d: Pull complete 
Digest: sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest
[root@docker ~]# 

2.运行容器

[root@docker ~]# docker run -it ba6acccedd29 /bin/bash
root@792de8cbe835:/# 

3.查看并安装vim

[root@docker ~]# docker run -it ba6acccedd29 /bin/bash
root@ce128f008eea:/# vim aaa.txt 
oot@ce128f008eea:/# apt-get update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [3221 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB] 
Get:8 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:9 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [1129 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]            
Get:11 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [29.3 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [3057 kB] 
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1433 kB]      
Get:14 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [3206 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [3709 kB]                                                                                                                                                                                                                                                        
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [32.0 kB]                                                                                                                                                                                                                                                  
Get:17 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [55.2 kB]                                                                                                                                                                                                                                                      
Get:18 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [28.6 kB]                                                                                                                                                                                                                                                  
Fetched 29.3 MB in 7s (4367 kB/s)                                                                                                                                                                                                                                                                                                          
Reading package lists... Done
root@ce128f008eea:/# apt-get install -y vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:alsa-topology-conf alsa-ucm-conf file libasound2 libasound2-data libcanberra0 libexpat1 libgpm2 libltdl7 libmagic-mgc libmagic1 libmpdec2 libogg0 libpython3.8 libpython3.8-minimal libpython3.8-stdlib libreadline8 libsqlite3-0 libssl1.1 libtdb1 libvorbis0a libvorbisfile3 mime-support readline-common sound-theme-freedesktopvim-common vim-runtime xxd xz-utils
Suggested packages:libasound2-plugins alsa-utils libcanberra-gtk0 libcanberra-pulse gpm readline-doc ctags vim-doc vim-scripts
The following NEW packages will be installed:alsa-topology-conf alsa-ucm-conf file libasound2 libasound2-data libcanberra0 libexpat1 libgpm2 libltdl7 libmagic-mgc libmagic1 libmpdec2 libogg0 libpython3.8 libpython3.8-minimal libpython3.8-stdlib libreadline8 libsqlite3-0 libssl1.1 libtdb1 libvorbis0a libvorbisfile3 mime-support readline-common sound-theme-freedesktop vimvim-common vim-runtime xxd xz-utils
0 upgraded, 30 newly installed, 0 to remove and 51 not upgraded.
Need to get 15.0 MB of archives.
After this operation, 70.6 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libmagic-mgc amd64 1:5.38-4 [218 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 libmagic1 amd64 1:5.38-4 [75.9 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/main amd64 file amd64 1:5.38-4 [23.3 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libexpat1 amd64 2.2.9-1ubuntu0.6 [74.6 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal/main amd64 libmpdec2 amd64 2.4.2-3 [81.1 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libssl1.1 amd64 1.1.1f-1ubuntu2.20 [1321 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8-minimal amd64 3.8.10-0ubuntu1~20.04.8 [717 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 mime-support all 3.64ubuntu1 [30.6 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal/main amd64 readline-common all 8.0-4 [53.5 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/main amd64 libreadline8 amd64 8.0-4 [131 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libsqlite3-0 amd64 3.31.1-4ubuntu0.5 [549 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8-stdlib amd64 3.8.10-0ubuntu1~20.04.8 [1675 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 xxd amd64 2:8.1.2269-1ubuntu5.20 [52.6 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 vim-common all 2:8.1.2269-1ubuntu5.20 [87.6 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 xz-utils amd64 5.2.4-1ubuntu1.1 [82.6 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal/main amd64 alsa-topology-conf all 1.2.2-1 [7364 B]
Get:17 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 alsa-ucm-conf all 1.2.2-1ubuntu0.13 [27.0 kB]
Get:18 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libasound2-data all 1.2.2-2.1ubuntu2.5 [20.1 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libasound2 amd64 1.2.2-2.1ubuntu2.5 [335 kB]
Get:20 http://archive.ubuntu.com/ubuntu focal/main amd64 libltdl7 amd64 2.4.6-14 [38.5 kB]
Get:21 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libtdb1 amd64 1.4.5-0ubuntu0.20.04.1 [44.2 kB]
Get:22 http://archive.ubuntu.com/ubuntu focal/main amd64 libogg0 amd64 1.3.4-0ubuntu1 [24.0 kB]
Get:23 http://archive.ubuntu.com/ubuntu focal/main amd64 libvorbis0a amd64 1.3.6-2ubuntu1 [87.0 kB]
Get:24 http://archive.ubuntu.com/ubuntu focal/main amd64 libvorbisfile3 amd64 1.3.6-2ubuntu1 [16.1 kB]
Get:25 http://archive.ubuntu.com/ubuntu focal/main amd64 sound-theme-freedesktop all 0.8-2ubuntu1 [384 kB]
Get:26 http://archive.ubuntu.com/ubuntu focal/main amd64 libcanberra0 amd64 0.30-7ubuntu1 [38.1 kB]
Get:27 http://archive.ubuntu.com/ubuntu focal/main amd64 libgpm2 amd64 1.20.7-5 [15.1 kB]
Get:28 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8 amd64 3.8.10-0ubuntu1~20.04.8 [1625 kB]
Get:29 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 vim-runtime all 2:8.1.2269-1ubuntu5.20 [5878 kB]
Get:30 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 vim amd64 2:8.1.2269-1ubuntu5.20 [1242 kB]
Fetched 15.0 MB in 5s (2983 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libmagic-mgc.
(Reading database ... 4127 files and directories currently installed.)
Preparing to unpack .../00-libmagic-mgc_1%3a5.38-4_amd64.deb ...
Unpacking libmagic-mgc (1:5.38-4) ...
Selecting previously unselected package libmagic1:amd64.
Preparing to unpack .../01-libmagic1_1%3a5.38-4_amd64.deb ...
Unpacking libmagic1:amd64 (1:5.38-4) ...
Selecting previously unselected package file.
Preparing to unpack .../02-file_1%3a5.38-4_amd64.deb ...
Unpacking file (1:5.38-4) ...
Selecting previously unselected package libexpat1:amd64.
Preparing to unpack .../03-libexpat1_2.2.9-1ubuntu0.6_amd64.deb ...
Unpacking libexpat1:amd64 (2.2.9-1ubuntu0.6) ...
Selecting previously unselected package libmpdec2:amd64.
Preparing to unpack .../04-libmpdec2_2.4.2-3_amd64.deb ...
Unpacking libmpdec2:amd64 (2.4.2-3) ...
Selecting previously unselected package libssl1.1:amd64.
Preparing to unpack .../05-libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb ...
Unpacking libssl1.1:amd64 (1.1.1f-1ubuntu2.20) ...
Selecting previously unselected package libpython3.8-minimal:amd64.
Preparing to unpack .../06-libpython3.8-minimal_3.8.10-0ubuntu1~20.04.8_amd64.deb ...
Unpacking libpython3.8-minimal:amd64 (3.8.10-0ubuntu1~20.04.8) ...
Selecting previously unselected package mime-support.
Preparing to unpack .../07-mime-support_3.64ubuntu1_all.deb ...
Unpacking mime-support (3.64ubuntu1) ...
Selecting previously unselected package readline-common.
Preparing to unpack .../08-readline-common_8.0-4_all.deb ...
Unpacking readline-common (8.0-4) ...
Selecting previously unselected package libreadline8:amd64.
Preparing to unpack .../09-libreadline8_8.0-4_amd64.deb ...
Unpacking libreadline8:amd64 (8.0-4) ...
Selecting previously unselected package libsqlite3-0:amd64.
Preparing to unpack .../10-libsqlite3-0_3.31.1-4ubuntu0.5_amd64.deb ...
Unpacking libsqlite3-0:amd64 (3.31.1-4ubuntu0.5) ...
Selecting previously unselected package libpython3.8-stdlib:amd64.
Preparing to unpack .../11-libpython3.8-stdlib_3.8.10-0ubuntu1~20.04.8_amd64.deb ...
Unpacking libpython3.8-stdlib:amd64 (3.8.10-0ubuntu1~20.04.8) ...
Selecting previously unselected package xxd.
Preparing to unpack .../12-xxd_2%3a8.1.2269-1ubuntu5.20_amd64.deb ...
Unpacking xxd (2:8.1.2269-1ubuntu5.20) ...
Selecting previously unselected package vim-common.
Preparing to unpack .../13-vim-common_2%3a8.1.2269-1ubuntu5.20_all.deb ...
Unpacking vim-common (2:8.1.2269-1ubuntu5.20) ...
Selecting previously unselected package xz-utils.
Preparing to unpack .../14-xz-utils_5.2.4-1ubuntu1.1_amd64.deb ...
Unpacking xz-utils (5.2.4-1ubuntu1.1) ...
Selecting previously unselected package alsa-topology-conf.
Preparing to unpack .../15-alsa-topology-conf_1.2.2-1_all.deb ...
Unpacking alsa-topology-conf (1.2.2-1) ...
Selecting previously unselected package alsa-ucm-conf.
Preparing to unpack .../16-alsa-ucm-conf_1.2.2-1ubuntu0.13_all.deb ...
Unpacking alsa-ucm-conf (1.2.2-1ubuntu0.13) ...
Selecting previously unselected package libasound2-data.
Preparing to unpack .../17-libasound2-data_1.2.2-2.1ubuntu2.5_all.deb ...
Unpacking libasound2-data (1.2.2-2.1ubuntu2.5) ...
Selecting previously unselected package libasound2:amd64.
Preparing to unpack .../18-libasound2_1.2.2-2.1ubuntu2.5_amd64.deb ...
Unpacking libasound2:amd64 (1.2.2-2.1ubuntu2.5) ...
Selecting previously unselected package libltdl7:amd64.
Preparing to unpack .../19-libltdl7_2.4.6-14_amd64.deb ...
Unpacking libltdl7:amd64 (2.4.6-14) ...
Selecting previously unselected package libtdb1:amd64.
Preparing to unpack .../20-libtdb1_1.4.5-0ubuntu0.20.04.1_amd64.deb ...
Unpacking libtdb1:amd64 (1.4.5-0ubuntu0.20.04.1) ...
Selecting previously unselected package libogg0:amd64.
Preparing to unpack .../21-libogg0_1.3.4-0ubuntu1_amd64.deb ...
Unpacking libogg0:amd64 (1.3.4-0ubuntu1) ...
Selecting previously unselected package libvorbis0a:amd64.
Preparing to unpack .../22-libvorbis0a_1.3.6-2ubuntu1_amd64.deb ...
Unpacking libvorbis0a:amd64 (1.3.6-2ubuntu1) ...
Selecting previously unselected package libvorbisfile3:amd64.
Preparing to unpack .../23-libvorbisfile3_1.3.6-2ubuntu1_amd64.deb ...
Unpacking libvorbisfile3:amd64 (1.3.6-2ubuntu1) ...
Selecting previously unselected package sound-theme-freedesktop.
Preparing to unpack .../24-sound-theme-freedesktop_0.8-2ubuntu1_all.deb ...
Unpacking sound-theme-freedesktop (0.8-2ubuntu1) ...
Selecting previously unselected package libcanberra0:amd64.
Preparing to unpack .../25-libcanberra0_0.30-7ubuntu1_amd64.deb ...
Unpacking libcanberra0:amd64 (0.30-7ubuntu1) ...
Selecting previously unselected package libgpm2:amd64.
Preparing to unpack .../26-libgpm2_1.20.7-5_amd64.deb ...
Unpacking libgpm2:amd64 (1.20.7-5) ...
Selecting previously unselected package libpython3.8:amd64.
Preparing to unpack .../27-libpython3.8_3.8.10-0ubuntu1~20.04.8_amd64.deb ...
Unpacking libpython3.8:amd64 (3.8.10-0ubuntu1~20.04.8) ...
Selecting previously unselected package vim-runtime.
Preparing to unpack .../28-vim-runtime_2%3a8.1.2269-1ubuntu5.20_all.deb ...
Adding 'diversion of /usr/share/vim/vim81/doc/help.txt to /usr/share/vim/vim81/doc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim81/doc/tags to /usr/share/vim/vim81/doc/tags.vim-tiny by vim-runtime'
Unpacking vim-runtime (2:8.1.2269-1ubuntu5.20) ...
Selecting previously unselected package vim.
Preparing to unpack .../29-vim_2%3a8.1.2269-1ubuntu5.20_amd64.deb ...
Unpacking vim (2:8.1.2269-1ubuntu5.20) ...
Setting up libexpat1:amd64 (2.2.9-1ubuntu0.6) ...
Setting up libgpm2:amd64 (1.20.7-5) ...
Setting up libogg0:amd64 (1.3.4-0ubuntu1) ...
Setting up mime-support (3.64ubuntu1) ...
Setting up alsa-ucm-conf (1.2.2-1ubuntu0.13) ...
Setting up libmagic-mgc (1:5.38-4) ...
Setting up libtdb1:amd64 (1.4.5-0ubuntu0.20.04.1) ...
Setting up libssl1.1:amd64 (1.1.1f-1ubuntu2.20) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Setting up libsqlite3-0:amd64 (3.31.1-4ubuntu0.5) ...
Setting up libmagic1:amd64 (1:5.38-4) ...
Setting up file (1:5.38-4) ...
Setting up xxd (2:8.1.2269-1ubuntu5.20) ...
Setting up libasound2-data (1.2.2-2.1ubuntu2.5) ...
Setting up vim-common (2:8.1.2269-1ubuntu5.20) ...
Setting up xz-utils (5.2.4-1ubuntu1.1) ...
update-alternatives: using /usr/bin/xz to provide /usr/bin/lzma (lzma) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/lzma.1.gz because associated file /usr/share/man/man1/xz.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/unlzma.1.gz because associated file /usr/share/man/man1/unxz.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzcat.1.gz because associated file /usr/share/man/man1/xzcat.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzmore.1.gz because associated file /usr/share/man/man1/xzmore.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzless.1.gz because associated file /usr/share/man/man1/xzless.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzdiff.1.gz because associated file /usr/share/man/man1/xzdiff.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzcmp.1.gz because associated file /usr/share/man/man1/xzcmp.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzgrep.1.gz because associated file /usr/share/man/man1/xzgrep.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzegrep.1.gz because associated file /usr/share/man/man1/xzegrep.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzfgrep.1.gz because associated file /usr/share/man/man1/xzfgrep.1.gz (of link group lzma) doesn't exist
Setting up libvorbis0a:amd64 (1.3.6-2ubuntu1) ...
Setting up libltdl7:amd64 (2.4.6-14) ...
Setting up alsa-topology-conf (1.2.2-1) ...
Setting up sound-theme-freedesktop (0.8-2ubuntu1) ...
Setting up libasound2:amd64 (1.2.2-2.1ubuntu2.5) ...
Setting up libmpdec2:amd64 (2.4.2-3) ...
Setting up vim-runtime (2:8.1.2269-1ubuntu5.20) ...
Setting up readline-common (8.0-4) ...
Setting up libpython3.8-minimal:amd64 (3.8.10-0ubuntu1~20.04.8) ...
Setting up libreadline8:amd64 (8.0-4) ...
Setting up libvorbisfile3:amd64 (1.3.6-2ubuntu1) ...
Setting up libpython3.8-stdlib:amd64 (3.8.10-0ubuntu1~20.04.8) ...
Setting up libcanberra0:amd64 (0.30-7ubuntu1) ...
Setting up libpython3.8:amd64 (3.8.10-0ubuntu1~20.04.8) ...
Setting up vim (2:8.1.2269-1ubuntu5.20) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/da/man1/vi.1.gz because associated file /usr/share/man/da/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/de/man1/vi.1.gz because associated file /usr/share/man/de/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/fr/man1/vi.1.gz because associated file /usr/share/man/fr/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/it/man1/vi.1.gz because associated file /usr/share/man/it/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ja/man1/vi.1.gz because associated file /usr/share/man/ja/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/pl/man1/vi.1.gz because associated file /usr/share/man/pl/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ru/man1/vi.1.gz because associated file /usr/share/man/ru/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/vi.1.gz because associated file /usr/share/man/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/da/man1/view.1.gz because associated file /usr/share/man/da/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/de/man1/view.1.gz because associated file /usr/share/man/de/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/fr/man1/view.1.gz because associated file /usr/share/man/fr/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/it/man1/view.1.gz because associated file /usr/share/man/it/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ja/man1/view.1.gz because associated file /usr/share/man/ja/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/pl/man1/view.1.gz because associated file /usr/share/man/pl/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ru/man1/view.1.gz because associated file /usr/share/man/ru/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/view.1.gz because associated file /usr/share/man/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/da/man1/ex.1.gz because associated file /usr/share/man/da/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/de/man1/ex.1.gz because associated file /usr/share/man/de/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/fr/man1/ex.1.gz because associated file /usr/share/man/fr/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/it/man1/ex.1.gz because associated file /usr/share/man/it/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ja/man1/ex.1.gz because associated file /usr/share/man/ja/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/pl/man1/ex.1.gz because associated file /usr/share/man/pl/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ru/man1/ex.1.gz because associated file /usr/share/man/ru/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/ex.1.gz because associated file /usr/share/man/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/da/man1/editor.1.gz because associated file /usr/share/man/da/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/de/man1/editor.1.gz because associated file /usr/share/man/de/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/fr/man1/editor.1.gz because associated file /usr/share/man/fr/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/it/man1/editor.1.gz because associated file /usr/share/man/it/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ja/man1/editor.1.gz because associated file /usr/share/man/ja/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/pl/man1/editor.1.gz because associated file /usr/share/man/pl/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ru/man1/editor.1.gz because associated file /usr/share/man/ru/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/editor.1.gz because associated file /usr/share/man/man1/vim.1.gz (of link group editor) doesn't exist
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
root@ce128f008eea:/# 

4.退出容器

root@ce128f008eea:/# exit
exit
[root@docker ~]# 

5提交自己的镜像

[root@docker ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND                   CREATED              STATUS                            PORTS     NAMES
dd90b084d152   ubuntu:latest   "/bin/bash"               About a minute ago   Up About a minute                           ubuntu_vim
ccb457c15659   mysql:5.6       "docker-entrypoint.s…"   49 minutes ago       Exited (1) 49 minutes ago                   relaxed_bartik
f919fcfcb7b0   hello-world     "/hello"                  19 hours ago         Exited (0) 19 hours ago                     fervent_benz
a4016a83fc04   hello-world     "/hello"                  23 hours ago         Exited (0) 23 hours ago                     hopeful_bardeen
f30bd054e899   9c7a54a9a43c    "/hello"                  40 hours ago         Exited (0) 40 hours ago                     mystifying_shockley
[root@docker ~]# docker commit -m="installed vim" -a="circle" dd90b084d152 cirlce/ubuntu:1.0
sha256:4eac314fbf24dffd018c0682a47044f4108f5fef02d8af5d6a79e91c8bfa0765
[root@docker ~]#

对比

[root@docker ~]# docker images
REPOSITORY      TAG       IMAGE ID       CREATED         SIZE
'cirlce/ubuntu'   1.0       4eac314fbf24   2 minutes ago   72.8MB
mysql           5.6       dd3b2a5dcb48   23 months ago   303MB
'ubuntu'          latest    ba6acccedd29   2 years ago     72.8MB
hello-world     latest    feb5d9fea6a5   2 years ago     13.3kB
[root@docker ~]# 

总结

  • Docker中的镜像分层,支持通过扩展现有镜像,创建新的镜像。类似Java继承于一个Base基础类,自己再按需扩展。
  • 新镜像是从 base 镜像一层一层叠加生成的。每安装一个软件,就在现有镜像的基础上增加一层

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/165409.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【数据结构/C++】线性表_双链表基本操作

#include <iostream> using namespace std; typedef int ElemType; // 3. 双链表 typedef struct DNode {ElemType data;struct DNode *prior, *next; } DNode, *DLinkList; // 初始化带头结点 bool InitDNodeList(DLinkList &L) {L (DNode *)malloc(sizeof(DNode))…

成为AI产品经理——模型评估概述

目录 一、模型宣讲和评估的原因 二、模型宣讲 三、模型评估 1. 重要特征 ① 特征来源 ②特征意义 2.选择测试样本 3.模型性能和稳定性 一、模型宣讲和评估的原因 刘海丰老师提到他们在做一个金融AI产品未注重模型指标&#xff0c;过于注重业务指标&#xff0c;导致产生…

解决:ImportError: cannot import name ‘Adam‘ from ‘keras.optimizers‘

解决&#xff1a;ImportError: cannot import name ‘Adam‘ from ‘keras.optimizers‘ 背景 在使用之前的代码时&#xff0c;报错&#xff1a; from keras.optimizers import Adam ImportError: cannot import name ‘Adam’ 报错问题 from keras.optimizers import Adam I…

【Java 进阶篇】Redis持久化之RDB:数据的安全守护者

Redis&#xff0c;作为一款高性能的键值存储系统&#xff0c;支持多种持久化方式&#xff0c;其中RDB&#xff08;Redis DataBase&#xff09;是其最常用的一种。RDB可以将当前时刻的数据快照保存到磁盘&#xff0c;以便在Redis重启时快速恢复数据。本文将深入探讨RDB的原理、配…

飞书智能伙伴之 AI 数智参谋:先进团队,北极星指标也要遥遥领先

11 月 22 日&#xff0c;飞书在 2023 秋季飞书未来无限大会上正式发布了飞书智能伙伴。作为首批生态伙伴&#xff0c;基于 Kyligence 智能一站式指标平台实现的 AI 数智参谋也正式亮相。这是继 11 月 21 日 Kyligence 产品发布会后&#xff0c;Kyligence 在数据驱动决策智能领域…

第十五届蓝桥杯(Web 应用开发)模拟赛 1 期-大学组(详细分析解答)

目录 1.动态的Tab栏 1.1 题目要求 1.2 题目分析 1.3 源代码 2.地球环游 2.1 题目要求 2.2 题目分析 2.3 源代码 3.迷惑的this 3.1 题目要求 3.2 题目分析 3.3 源代码 4.魔法失灵了 4.1 题目要求 4.2 题目分析 4.3 源代码 5.燃烧你的卡路里 5.1 题目要求 5.2…

第十七章:数据库操作

数据库基础 SQL语言 1、select 语句 select 语句用于从数据中检索数据。语法如下&#xff1a; SELECT 搜选字段列表 FROM 数据表名 WHERE 条件表达式 GROUP BY 字段名 HAVING 条件表达式(指定分组的条件) ORDER BY 字段名[ASC|DESC] 2、insert 语句 insert 语句用于向表中插入…

【UE5】五大基类及其使用

UObject UObject表示对象&#xff0c;准确来说&#xff0c;虚幻引擎中的对象基础类为UObject UObject提供了以下功能&#xff1a; 垃圾收集&#xff08;Garbage collection&#xff09;引用自动更新&#xff08;Reference updating&#xff09;反射&#xff08;Reflection&am…

计算机基础知识57

前后端数据传输的编码格式(contentType) # 我们只研究post请求方式的编码格式&#xff1a; get请求方式没有编码格式-- index?useranme&password get请求方式没有请求体&#xff0c;参数直接在url地址的后面拼接着 # 有哪些方式可以提交post请求&#xff1a;f…

构建个性化预约服务:预约上门服务系统源码解读与实战

随着社会的发展&#xff0c;预约上门服务系统在满足用户需求、提升服务效率方面发挥着越来越重要的作用。在本文中&#xff0c;我们将深入研究预约上门服务系统的源码&#xff0c;通过实际的技术代码示例&#xff0c;揭示系统内部的关键机制&#xff0c;以及如何在实际项目中应…

深入了解接口测试:方法、工具和关键考虑因素(一)

接口测试是软件测试中的一项重要工作&#xff0c;它涉及到系统与系统之间的交互点。接口可以是外部接口&#xff0c;也可以是内部接口&#xff0c;包括上层服务与下层服务接口以及同级接口。在接口测试中&#xff0c;我们需要确保接口能够按照预期的方式进行通信和交互&#xf…

【攻防世界-misc】can_has_stdio?

1.用记事本打开文件是这样子的&#xff0c; 这是一段BF&#xff08;Brainfuck&#xff09;编程语言代码&#xff0c;属于一种极简化的编程语言&#xff0c;用于演示计算机程序设计概念。这段代码包含了一些操作符&#xff0c;如">"表示指针向右移动&#xff0c;&q…

【C++破局】泛型编程|函数模板|类模板

​作者主页 &#x1f4da;lovewold少个r博客主页 ⚠️本文重点&#xff1a;c模板初阶知识点讲解 &#x1f449;【C-C入门系列专栏】&#xff1a;博客文章专栏传送门 &#x1f604;每日一言&#xff1a;花有重开日&#xff0c;人无再少年 目录 前言 泛型编程 函数模板 函数模…

用Java实现简易的图书管理系统(超详细)

目录 1.设计背景 2.设计思路 3.模块展示及代码演示 3.1 Book类的实现 3.2 BookList类的实现(书架) 3.3 异常类的实现(OperationException) 3.4 用户类的实现 3.5 操作接口的实现(定义规范) 3.6 操作类的具体实现 3.6.1 增加操作 3.6.2 查找操作 3.6.3 删除操作 3.6…

标签打印机打印标签时出现,数据处理过程中错误 无法设置项目 图片1的内容无法打印

环境&#xff1a; Win10专业版 NiceLabel Designer 10.1 问题描述&#xff1a; 标签打印机打印标签时出现&#xff0c;数据处理过程中错误 无法设置项目 图片1的内容无法打印 解决方案&#xff1a; 1.删除标签部分文字打印测试 还是一样&#xff08;未解决&#xff09; …

jenkins 参数构建

应用保存 [rootjenkins-node1 .ssh]# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved i…

【嵌入式面试】2022年嵌入式经典面试题汇总(C语言)

&#x1f4dc;作者&#xff1a;不想脱发的基兄 &#x1f4fa;专栏&#xff1a;《嵌入式面试》 &#x1f4e3;格言&#xff1a;不管前方的路有多苦&#xff0c;只要走的方向正确&#xff0c;不管多么崎岖不平&#xff0c;都比站在原地更接近幸福。 前言&#xff1a; 2022年秋招我…

C++之初始化列表详细剖析

一、初始化列表定义 初始化列表&#xff1a;以一个冒号开始&#xff0c;接着是一个以逗号分隔的数据成员列表&#xff0c;每个"成员变量"后面跟一个放在括号中的初始值或表达式。 class Date { public:Date(int year, int month, int day): _year(year), _month(mont…

OpenCV快速入门:图像分析——图像分割和图像修复

文章目录 前言一、图像分割1.1 漫水填充法1.1.1 漫水填充法原理1.1.2 漫水填充法实现步骤1.1.3 代码实现 1.2 分水岭法1.2.1 分水岭法原理1.2.2 分水岭法实现步骤1.2.3 代码实现 1.3 GrabCut法1.3.1 GrabCut法原理1.3.2 GrabCut法实现步骤1.3.3 代码实现 1.4 Mean-Shift法1.4.1…

多级缓存快速上手

哈喽~大家好&#xff0c;这篇来看看多级缓存。 &#x1f947;个人主页&#xff1a;个人主页​​​​​ &#x1f948; 系列专栏&#xff1a;【微服务】 &#x1f949;与这篇相关的文章&#xff1a; JAVA进程和线程JAVA进程和线程-CSDN博客Http…