2. Docker - 安装
bash-3.2# yum -y install epel-release
bash-3.2# yum update
bash-3.2# yum -y install docker-io
bash-3.2# /etc/init.d/docker start
bash-3.2# chkconfig --add docker
bash-3.2# chkconfig docker on
bash-3.2# ps aux|grep docker
root 1396 1 0 May20 ? 00:15:31 /usr/bin/docker -d
bash-3.2# docker pull centos
bash-3.2# docker images
centos latest 2a332da70fd1 2 weeks ago 196.7 MB
bash-3.2# docker tag centos:latest 90root:90root
bash-3.2# docker images
centos latest 2a332da70fd1 2 weeks ago 196.7 MB
90root 90root 2a332da70fd1 2 weeks ago 196.7 MB
###可以看到,其实基于centos:latest拷贝一份镜像. 仔细看发现两者IMAGE ID一样.
bash-3.2# docker search centos
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
centos The official build of CentOS. 2358 [OK]
ansible/centos7-ansible Ansible on Centos7 75 [OK]
jdeathe/centos-ssh CentOS-6 6.7 x86_64 / CentOS-7 7.2.1511 x8... 25 [OK]
jdeathe/centos-ssh-apache-php CentOS-6 6.7 x86_64 / Apache / PHP / PHP M... 17 [OK]
nimmis/java-centos This is docker images of CentOS 7 with dif... 12 [OK]
………………………………………………
bash-3.2# docker run -it centos /bin/bash
bash-96d50d4ae5e4# exit
##退出容器之后,容器停止
## -i: 让容器的标准输入打开
## -t: 为容器分配一个为终端
bash-3.2# docker ps #查看正在运行的容器
bash-3.2# docker ps -a #查看所有容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
96d50d4ae5e4 centos "/bin/bash" 4 minutes ago Exited (0) 3 minutes ago desperate_hopper
bash-3.2# docker images #查看镜像
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
90root 0617 b14c8813ddbd 3 days ago 513.4 MB
90root 90root 2a332da70fd1 2 weeks ago 196.7 MB
centos latest 2a332da70fd1 2 weeks ago 196.7 MB
bash-3.2# docker rmi docker rmi 90root:0617 #删除镜像
bash-3.2# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos latest 2a332da70fd1 2 weeks ago 196.7 MB
90root 90root 2a332da70fd1 2 weeks ago 196.7 MB
## 不推荐通过镜像id删除镜像
优质内容筛选与推荐>>