- 环境: Linux Centos-7.5 联网状态 (需要最少RHEL6.5以上版本,64位操作系统)
- 利用的yum源(阿里源): http://mirrors.aliyun.com/repo/Centos-7.repo
1、查看是否已经安装过docker
[root@python3 ~]# yum list installed | grep docker
docker.x86_64 2:1.13.1-108.git4ef4b30.el7.centos
docker-client.x86_64 2:1.13.1-108.git4ef4b30.el7.centos
docker-common.x86_64 2:1.13.1-108.git4ef4b30.el7.centos
2、以上表示已经安装过,删除docker
[root@python3 ~]# yum remove -y docker.x86_64 && yum remove -y docker-client && yum remove -y docker-common
3.下载阿里Yum源到指定的位置
[root@python3 ~]# wget -O /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
4.如果用上述命令报错,如下:
[root@python3 ~]# wget -O /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
-bash: /usr/bin/wget: 没有那个文件或目录
解决办法:
[root@python3 ~]# yum -y install wget
安装wget,并执行下载yum源命令
5.查看yum源的安装包数量,确定是否正确
[root@python3 ~]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
源标识 源名称 状态
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,097
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 323
local_repo CentOS-7 - Base 9,911
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 1,446
repolist: 21,777
6.用yum安装docker,自动解决依赖
[root@python3 ~]# yum -y install docker
.........
已安装:
docker.x86_64 2:1.13.1-108.git4ef4b30.el7.centos
作为依赖被安装:
docker-client.x86_64 2:1.13.1-108.git4ef4b30.el7.centos
docker-common.x86_64 2:1.13.1-108.git4ef4b30.el7.centos
7.启动docker,并开机自启,确定docker是否安装成功,成功会形成docker0虚拟网卡
[root@python3 ~]# systemctl restart docker
[root@python3 ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@python3 ~]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
ether 02:42:4e:eb:b1:77 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.11 netmask 255.255.255.0 broadcast 192.168.1.255
ether 52:54:00:fd:7e:63 txqueuelen 1000 (Ethernet)
RX packets 161342 bytes 174859557 (166.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 89253 bytes 154706996 (147.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 13714 bytes 130086976 (124.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 13714 bytes 130086976 (124.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
8.下载docker-centos镜像
[root@python3 ~]# docker pull centos
Using default tag: latest
Trying to pull repository docker.io/library/centos ...
latest: Pulling from docker.io/library/centos
8a29a15cefae: Pull complete
Digest: sha256:fe8d824220415eed5477b63addf40fb06c3b049404242b31982106ac204f6700
Status: Downloaded newer image for docker.io/centos:latest
[root@python3 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos latest 470671670cac 3 weeks ago 237 MB