Centos7安装Docker
原创
©著作权归作者所有:来自51CTO博客作者踏行天下的原创作品,请联系作者获取转载授权,否则将追究法律责任
Centos7安装Docker
安装Docker
1. [root@localhost ~]# yum install docker -y
查看docker版本
1. [root@localhost ~]# docker version
设置为开机启动
1. [root@localhost ~]# systemctl start docker.service
2. [root@localhost ~]# systemctl enable docker.service
3. [root@localhost ~]# service docker restart
4. [root@localhost ~]# ps -ef|grep docker
5. [root@localhost ~]# service docker stop
6. [root@localhost ~]# ifconfig
7. [root@localhost ~]# service docker start
8. [root@localhost ~]# ifconfig
9.
10.
11. [root@localhost ~]# docker images
12. [root@localhost ~]# docker ps -a
下载官方的 CentOS 镜像到本地
1. [root@localhost ~]# docker pull centos
2. [root@localhost ~]# docker images
3. REPOSITORY TAG IMAGE ID CREATED SIZE
4. docker.io/centos latest 3bee3060bfc8 3 weeks ago 192.5 MB
运行一个 Docker 容器
1. [root@localhost ~]# docker run -i -t docker.io/centos /bin/bash
2. [root@3aee75b07ec2 /]# cat /etc/redhat-release
3. CentOS Linux release 7.3.1611 (Core)
4. [root@3aee75b07ec2 /]#
5. [root@3aee75b07ec2 /]# exit
6.
7.
8.
9.
10. [root@localhost ~]# docker ps -a
11. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
12. 3aee75b07ec2 docker.io/centos "/bin/bash" 3 minutes ago Exited (0) 4 seconds ago pensive_jones
13. [root@localhost ~]#