Centos7安装Docker
安装Docker
- [root@localhost ~]# yum install docker -y
查看docker版本
- [root@localhost ~]# docker version
设置为开机启动
- [root@localhost ~]# systemctl start docker.service
- [root@localhost ~]# systemctl enable docker.service
- [root@localhost ~]# service docker restart
- [root@localhost ~]# ps -ef|grep docker
- [root@localhost ~]# service docker stop
- [root@localhost ~]# ifconfig
- [root@localhost ~]# service docker start
- [root@localhost ~]# ifconfig
- [root@localhost ~]# docker images
- [root@localhost ~]# docker ps -a
下载官方的 CentOS 镜像到本地
- [root@localhost ~]# docker pull centos
- [root@localhost ~]# docker images
- REPOSITORY TAG IMAGE ID CREATED SIZE
- docker.io/centos latest 3bee3060bfc8 3 weeks ago 192.5 MB
运行一个 Docker 容器
- [root@localhost ~]# docker run -i -t docker.io/centos /bin/bash
- [root@3aee75b07ec2 /]# cat /etc/redhat-release
- CentOS Linux release 7.3.1611 (Core)
- [root@3aee75b07ec2 /]#
- [root@3aee75b07ec2 /]# exit
- [root@localhost ~]# docker ps -a
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- 3aee75b07ec2 docker.io/centos "/bin/bash" 3 minutes ago Exited (0) 4 seconds ago pensive_jones
- [root@localhost ~]#