Docker從零開始學(xué)習(xí)之Commit提交命令
前言
了解commit命令之前我們先了解下涉及的相關(guān)知識(shí)
為什么這里又說鏡像,因?yàn)橹傲私獾闹皇莻€(gè)大概,現(xiàn)在涉及鏡像的原理
基本概念
鏡像
- 是一種輕量級(jí)、可執(zhí)行的獨(dú)立軟件包,它包含運(yùn)行某個(gè)軟件所需的所有內(nèi)容,我們把應(yīng)用程序和配置依賴打包好形成一個(gè)可交付的運(yùn)行環(huán)境(包括代碼、運(yùn)行時(shí)需要的庫、環(huán)境變量和配置文件等),這個(gè)打包好的運(yùn)行環(huán)境就是image鏡像文件。
- 只有通過這個(gè)鏡像文件才能生成Docker容器實(shí)例(類似Java中new出來一個(gè)對(duì)象)。
鏡像分層
什么是鏡像分層
- “鏡像是有分層的”
- 如圖所示:
- 如圖所示:
- 鏡像的使用的文件技術(shù)是UnionFS
- UnionFS(聯(lián)合文件系統(tǒng))
- UnionFS(聯(lián)合文件系統(tǒng)):Union文件系統(tǒng)(UnionFS)是一種分層、輕量級(jí)并且高性能的文件系統(tǒng),它支持對(duì)文件系統(tǒng)的修改作為一次提交來一層層的疊加,同時(shí)可以將不同目錄掛載到同一個(gè)虛擬文件系統(tǒng)下(unite several directories into a single virtual filesystem)。Union 文件系統(tǒng)是 Docker 鏡像的基礎(chǔ)。鏡像可以通過分層來進(jìn)行繼承,基于基礎(chǔ)鏡像(沒有父鏡像),可以制作各種具體的應(yīng)用鏡像。
- 特性:一次同時(shí)加載多個(gè)文件系統(tǒng),但從外面看起來,只能看到一個(gè)文件系統(tǒng),聯(lián)合加載會(huì)把各層文件系統(tǒng)疊加起來,這樣最終的文件系統(tǒng)會(huì)包含所有底層的文件和目錄
- UnionFS(聯(lián)合文件系統(tǒng))
- Docker鏡像加載原理:
- Docker的鏡像實(shí)際上由一層一層的文件系統(tǒng)組成,這種層級(jí)的文件系統(tǒng)UnionFS。
- Bootfs(boot file system)主要包含bootloader和kernel, bootloader主要是引導(dǎo)加載kernel, Linux剛啟動(dòng)時(shí)會(huì)加載bootfs文件系統(tǒng),在Docker鏡像的最底層是引導(dǎo)文件系統(tǒng)bootfs。這一層與我們典型的Linux/Unix系統(tǒng)是一樣的,包含boot加載器和內(nèi)核。當(dāng)boot加載完成之后整個(gè)內(nèi)核就都在內(nèi)存中了,此時(shí)內(nèi)存的使用權(quán)已由bootfs轉(zhuǎn)交給內(nèi)核,此時(shí)系統(tǒng)也會(huì)卸載Bootfs。
- rootfs (root file system) ,在bootfs之上。包含的就是典型 Linux 系統(tǒng)中的 /dev, /proc, /bin, /etc 等標(biāo)準(zhǔn)目錄和文件。rootfs就是各種不同的操作系統(tǒng)發(fā)行版,比如Ubuntu,Centos等等。
對(duì)于一個(gè)精簡(jiǎn)的OS,rootfs可以很小,只需要包括最基本的命令、工具和程序庫就可以了,因?yàn)榈讓又苯佑肏ost的kernel,自己只需要提供 rootfs 就行了。由此可見對(duì)于不同的linux發(fā)行版, bootfs基本是一致的, rootfs會(huì)有差別, 因此不同的發(fā)行版可以公用bootfs。
為什么 Docker 鏡像要采用這種分層結(jié)構(gòu)
- 比如說有多個(gè)鏡像都從相同的 base 鏡像構(gòu)建而來,那么 Docker Host 只需在磁盤上保存一份 base 鏡像;
同時(shí)內(nèi)存中也只需加載一份 base 鏡像,就可以為所有容器服務(wù)了。而且鏡像的每一層都可以被共享。
本章要點(diǎn)
- Docker鏡像層都是只讀的,容器層是可寫的。
- 當(dāng)容器啟動(dòng)時(shí),一個(gè)新的可寫層被加載到鏡像的頂部。這一層通常被稱作“容器層”,“容器層”之下的都叫“鏡像層”。
- 所有對(duì)容器的改動(dòng) - 無論添加、刪除、還是修改文件都只會(huì)發(fā)生在容器層中。只有容器層是可寫的,容器層下面的所有鏡像層都是只讀的。
commit 命令
- docker commit 命令用于根據(jù) Docker容器 的更改創(chuàng)建一個(gè)新的 Dokcer鏡像。該命令后面的 CONTAINER 可以是容器Id,或者是容器名。
命令格式
docker commit -m="[提交的描述信息]" -a="[作者]" [容器ID] [新的鏡像名稱]:[新的鏡像標(biāo)簽]
docker commit 操作參數(shù)
參數(shù) | 描述 |
---|---|
-a, --author string | 作者。 |
-c, --change list | 應(yīng)用 dockerfile 指令來創(chuàng)建圖像。 |
-m, --message | string |
-p, --pause | 提交期間暫停容器(默認(rèn)為true)。 |
實(shí)例演示
1.下載一個(gè)新的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.運(yùn)行容器
[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-freedesktop vim-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 vim vim-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 ~]#
對(duì)比
[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 ~]#
總結(jié)
- Docker中的鏡像分層,支持通過擴(kuò)展現(xiàn)有鏡像,創(chuàng)建新的鏡像。類似Java繼承于一個(gè)Base基礎(chǔ)類,自己再按需擴(kuò)展。
- 新鏡像是從 base 鏡像一層一層疊加生成的。每安裝一個(gè)軟件,就在現(xiàn)有鏡像的基礎(chǔ)上增加一層
到此這篇關(guān)于Docker從零開始學(xué)習(xí)之Commit提交命令的文章就介紹到這了,更多相關(guān)Docker Commit提交命令內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Docker安裝MongoDB并使用Navicat連接的操作方法
MongoDB是一個(gè)基于分布式文件存儲(chǔ)的數(shù)據(jù)庫,MongoDB最大的特點(diǎn)是它支持的查詢語言非常強(qiáng)大,其語法有點(diǎn)類似于面向?qū)ο蟮牟樵冋Z言,幾乎可以實(shí)現(xiàn)類似關(guān)系數(shù)據(jù)庫單表查詢的絕大部分功能,這篇文章主要介紹了Docker安裝MongoDB并使用Navicat連接,需要的朋友可以參考下2022-10-10使用Docker部署Nacos并配置MySQL數(shù)據(jù)源的詳細(xì)步驟
Nacos是阿里巴巴開源的服務(wù)發(fā)現(xiàn)、配置管理和服務(wù)管理平臺(tái),它提供了注冊(cè)中心和配置中心的功能,能夠輕松地管理微服務(wù)的注冊(cè)與發(fā)現(xiàn),以及動(dòng)態(tài)配置的管理,這篇文章主要給大家介紹了關(guān)于使用Docker部署Nacos并配置MySQL數(shù)據(jù)源的超詳細(xì)步驟,需要的朋友可以參考下2024-05-05Docker部署verdaccio搭建npm私服的實(shí)現(xiàn)
本女王主要介紹了Docker部署verdaccio搭建npm私服的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2025-02-02docker內(nèi)的容器如何與宿主機(jī)共享IP的方法
本文主要介紹了docker內(nèi)的容器如何與宿主機(jī)共享IP的方法,文中根據(jù)實(shí)例編碼詳細(xì)介紹的十分詳盡,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03docker容器狀態(tài)的轉(zhuǎn)換實(shí)現(xiàn)
這篇文章主要介紹了docker容器狀態(tài)的轉(zhuǎn)換實(shí)現(xiàn),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-11-11Docker配置本地倉庫web訪問的實(shí)現(xiàn)
本文主要介紹了Docker配置本地倉庫web訪問的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-06-06