Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | Email

159.2. 鏡像

Docker 鏡像地址 https://registry.hub.docker.com/

159.2.1. 搜索鏡像

$ sudo docker search centos |more
NAME                                            DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
centos                                          The official build of CentOS.                   542       [OK]       
tianon/centos                                   CentOS 5 and 6, created using rinse instea...   28                   
ansible/centos7-ansible                         Ansible on Centos7                              13                   [OK]
saltstack/centos-6-minimal                                                                      7                    [OK]
blalor/centos                                   Bare-bones base CentOS 6.5 image                7                    [OK]
steeef/graphite-centos                          CentOS 6.x with Graphite and Carbon via ng...   6                    [OK]
ariya/centos6-teamcity-server                   TeamCity Server 8.1 on CentOS 6                 6                    [OK]
tutum/centos                                    Centos image with SSH access. For the root...   5                    [OK]
tutum/centos-6.4                                DEPRECATED. Use tutum/centos:6.4 instead. ...   5                    [OK]			
			

159.2.2. 獲取鏡像

可以使用 docker pull 命令來從官網倉庫獲取所需要的鏡像。

$ sudo docker pull ubuntu:14.04
			

等同於

$ sudo docker pull registry.hub.docker.com/ubuntu:14.04
			

獲得所有版本鏡像

$ sudo docker pull ubuntu	

$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu              utopic              277eb4304907        3 days ago          215.6 MB
ubuntu              14.10               277eb4304907        3 days ago          215.6 MB
ubuntu              14.04               5506de2b643b        3 days ago          197.8 MB
ubuntu              trusty              5506de2b643b        3 days ago          197.8 MB
ubuntu              latest              5506de2b643b        3 days ago          197.8 MB
ubuntu              14.04.1             5506de2b643b        3 days ago          197.8 MB
ubuntu              precise             0b310e6bf058        3 days ago          116.1 MB
ubuntu              12.04.5             0b310e6bf058        3 days ago          116.1 MB
ubuntu              12.04               0b310e6bf058        3 days ago          116.1 MB
ubuntu              12.10               c5881f11ded9        4 months ago        172.1 MB
ubuntu              quantal             c5881f11ded9        4 months ago        172.1 MB
ubuntu              13.04               463ff6be4238        4 months ago        169.4 MB
ubuntu              raring              463ff6be4238        4 months ago        169.4 MB
ubuntu              13.10               195eb90b5349        4 months ago        184.6 MB
ubuntu              saucy               195eb90b5349        4 months ago        184.6 MB
ubuntu              10.04               3db9c44f4520        6 months ago        183 MB
ubuntu              lucid               3db9c44f4520        6 months ago        183 MB		
			

從其他伺服器獲得鏡像

$ sudo docker pull dl.dockerpool.com:5000/ubuntu:12.04
			

完成後,即可隨時使用該鏡像了,例如創建一個容器,讓其中運行 bash 應用。

$ sudo docker run -t -i ubuntu:14.10 /bin/bash
			

159.2.3. 列出本地鏡像

$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu              14.10               277eb4304907        3 days ago          215.6 MB
ubuntu              latest              5506de2b643b        3 days ago          197.8 MB
			

159.2.4. 創建鏡像


			

159.2.5. 保存和載入鏡像

保存鏡像

$sudo docker save -o ubuntu_14.10.tar ubuntu:14.10			
			

載入鏡像

			
$ sudo docker load --input ubuntu_14.10.tar
或
$ sudo docker load < ubuntu_14.10.tar
						
			

159.2.6. 刪除本地鏡像

$ sudo docker rmi ubuntu:12.04
Untagged: ubuntu:12.04