root@hadoop14 service docker start root@hadoop14 chkconfig docker on
3)翻墙下载镜像
注意:我是通过翻墙才下载的,出现下面Status:就表示下载完毕。
docker search ubuntu sudo docker pull ubuntu
4)列出本地镜像和进入镜像
在列出信息中,可以看到几个字段信息: 来自于哪个仓库,比如 ubuntu 镜像的标记,比如 14.04 它的 ID 号(唯一) 创建时间 镜像大小
[root@hadoop14 ~]# docker imagesREPOSITORYTAGIMAGEIDCREATEDVIRTUALSIZE
ubuntu latest 65e1e9d1a19f Less than a second ago 126.4MB
[root@hadoop14 ~]# docker run -t -i ubuntu:latest /bin/bash
root@78f0680738e4:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
[root@95067ff0a86a ~]# docker run ubuntu:14.04 /bin/echo
[root@95067ff0a86a ~]# exit
[root@hadoop14 ~]# sudo docker commit -m "Added fcae470ed1de" -a "Docker Newbee" 95067ff0a86a ubuntu:v295067ff0a86a96b8b599a2447356b8ccdf1d3803b15d0d4abf786a1955527214
[root@hadoop14 ~]# docker imagesREPOSITORYTAGIMAGEIDCREATEDVIRTUALSIZE
ubuntu latest 65e1e9d1a19f Less than a second ago 126.4MB
ubuntu v2 95067ff0a86a 4 seconds ago 126.4MB
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
6)存出和载入镜像
[root@hadoop14 ~]# docker save -o ubuntu_v2.tar ubuntu:v2
[root@hadoop14 ~]# du -sh ubuntu_v2.tar 126M ubuntu_v2.tar
[root@hadoop14 ~]# docker rmi -f ubuntu:v2Untagged:ubuntu:v2
Deleted:95067ff0a86a96b8b599a2447356b8ccdf1d3803b15d0d4abf786a1955527214
[root@hadoop14 ~]#
[root@hadoop14 ~]# docker load --input ubuntu_v2.tar
[root@hadoop14 ~]# docker imagesREPOSITORYTAGIMAGEIDCREATEDVIRTUALSIZE
ubuntu latest 65e1e9d1a19f Less than a second ago 126.4MB
ubuntu v2 95067ff0a86a 46 minutes ago 126.4MB
1
2
3
4
5
6
7
8
9
10
11
12
1
2
3
4
5
6
7
8
9
10
11
12
7)移除本地镜像
[root@hadoop14 ~]# docker imagesREPOSITORYTAGIMAGEIDCREATEDVIRTUALSIZE
ubuntu latest 65e1e9d1a19f Less than a second ago 126.4MB
ubuntu v3 5c449afd3746 4 seconds ago 126.4MB
ubuntu v2 95067ff0a86a 21 minutes ago 126.4MB
[root@hadoop14 ~]# docker rmi ubuntu:v3Untagged:ubuntu:v3
Deleted:5c449afd3746b22725f61371cc76ae485a639b6e5bd1711d363e2a1ae97be949
[root@hadoop14 ~]# docker imagesREPOSITORYTAGIMAGEIDCREATEDVIRTUALSIZE
ubuntu latest 65e1e9d1a19f Less than a second ago 126.4MB
ubuntu v2 95067ff0a86a 22 minutes ago 126.4MB