|
1.从docker hub中下载ubuntu14.04的镜像
root@ubuntu02:~# docker pull ubuntu:14.04
14.04: Pulling from library/ubuntu
050aa9ae81a9: Pull complete
1eb2c989bc04: Pull complete
f5e83780ccda: Pull complete
2dec31d7323c: Pull complete
286f32949bdc: Pull complete
Digest: sha256:084989eb923bd86dbf7e706d464cf3587274a826b484f75b69468c19f8ae354c
Status: Downloaded newer image for ubuntu:14.04
root@ubuntu02:~#
2.查看所下载镜像的信息, IMAGE ID是镜像唯一标记信息
root@ubuntu02:~# docker images ubuntu
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 14.04 67759a80360c 4 days ago 221MB
3.使用ubuntu14.04镜像创建一个容器,并运行bash应用
root@ubuntu02:~# docker run -it ubuntu:14.04 bash
root@f98509a7db40:/# ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.031 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.080 ms
^C
--- localhost ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.031/0.055/0.080/0.025 ms
root@f98509a7db40:/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 49G 1.9G 45G 5% /
tmpfs 64M 0 64M 0% /dev
tmpfs 240M 0 240M 0% /sys/fs/cgroup
/dev/sda2 49G 1.9G 45G 5% /etc/hosts
shm 64M 0 64M 0% /dev/shm
tmpfs 240M 0 240M 0% /proc/scsi
tmpfs 240M 0 240M 0% /sys/firmware
root@f98509a7db40:/# cat /etc/issue
Ubuntu 14.04.5 LTS \n \l
root@f98509a7db40:/# uname -r
4.4.0-31-generic
root@f98509a7db40:/# uname -a
Linux f98509a7db40 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
root@f98509a7db40:/#
4.tag一个镜像标签
root@ubuntu02:~# docker images ubuntu
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 14.04 67759a80360c 4 days ago 221MB
root@ubuntu02:~# docker tag ubuntu:14.04 ubuntu:14.04_Nginx
root@ubuntu02:~# docker images ubuntu
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 14.04 67759a80360c 4 days ago 221MB
ubuntu 14.04_Nginx 67759a80360c 4 days ago 221MB
root@ubuntu02:~#
可以发现ubuntu 14.04 和 ubuntu 14.04_Nginx 的 IMAGE ID是一样的,他们其实是指向同一个镜像,只是别名不同而已,起到一个类似链接的作用。
5.查看镜像的详细信息
root@ubuntu02:~# docker inspect ubuntu:14.04_Nginx
[
{
"Id": "sha256:67759a80360cbaef77ec1eee8aa0590f07ba04c26ef496efbc90391f217fd9d6",
"RepoTags": [
"ubuntu:14.04",
"ubuntu:14.04_Nginx"
],
"RepoDigests": ["ubuntu@sha256:084989eb923bd86dbf7e706d464cf3587274a826b484f75b69468c19f8ae354c"br/>root@ubuntu02:~# |
|
|