2、docker安装-docker+k8s+kubesphere
卸载以前的docker
yum remove -y docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine \docker-selinux
查看可用的docker版本
yum list docker-ce --showduplicates | sort -r
或者
yum list docker-ce --showduplicates----------------------------------------------------
结果如下
----------------------------------------------------
[root@node151 ~]# yum list docker-ce --showduplicates | sort -r
已加载插件:fastestmirror
可安装的软件包* updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile* extras: mirrors.aliyun.com
docker-ce.x86_64 3:19.03.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.12-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.11-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.10-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable* base: mirrors.aliyun.com
这里版本不要用最新的版本,肯能后面与到降级的问题,安装18最后一个版本18.09.9
安装docker18.09.9-3.el7
指定版本安装yum -y install docker-ce-18.09.9-3.el7 docker-ce-cli-18.09.9
参考:最新版本安装
yum install -y docker-ce
启动docker并设置开机自启
systemctl enable docker && systemctl start docker
相关命令
service docker start 启动
service docker restart 重启
service docker stop 停止
docker重新读取配置文件,重新启动docker服务
systemctl daemon-reload
systemctl restart docker
查看状态
systemctl status docker.service
配置阿里云docker镜像加速
cat > /etc/docker/daemon.json <<-'EOF'
{"registry-mirrors": ["https://3h9ba4le.mirror.aliyuncs.com"]
}
EOF#重启docker
systemctl daemon-reload
systemctl restart docker
检查加速器是否生效
[root@node151 ~]# docker info
Client:Debug Mode: falseServer:Containers: 0Running: 0Paused: 0Stopped: 0Images: 0Server Version: 18.09.9Storage Driver: overlay2Backing Filesystem: xfsSupports d_type: trueNative Overlay Diff: trueLogging Driver: json-fileCgroup Driver: cgroupfsPlugins:Volume: localNetwork: bridge host macvlan null overlayLog: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslogSwarm: inactiveRuntimes: runcDefault Runtime: runcInit Binary: docker-initcontainerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429runc version: dc9208a3303feef5b3839f4323d9beb36df0a9ddinit version: fec3683Security Options:seccompProfile: defaultKernel Version: 3.10.0-1127.13.1.el7.x86_64Operating System: CentOS Linux 7 (Core)OSType: linuxArchitecture: x86_64CPUs: 8Total Memory: 11.28GiBName: node151ID: 2I7M:Q5U2:GAZM:KGI2:L74R:7JLB:X7JZ:SK6B:3MXD:44VQ:6OVK:RFM3Docker Root Dir: /var/lib/dockerDebug Mode: falseRegistry: https://index.docker.io/v1/Labels:Experimental: falseInsecure Registries:127.0.0.0/8Registry Mirrors:https://3h9ba4le.mirror.aliyuncs.com/ 加速器在这里Live Restore Enabled: falseProduct License: Community Engine
阿里的加速申请,参考https://cr.console.aliyun.com/
docker安装完成后才会有daemon.json文件
cat /etc/docker/daemon.json
参考其他的加速器
{
“registry-mirrors” : [
“https://3h9ba4le.mirror.aliyuncs.com”,
“https://docker.mirrors.ustc.edu.cn”,
“https://hub-mirror.c.163.com”,
“https://reg-mirror.qiniu.com”
],
“storage-driver” : “devicemapper”
}
修改docker Cgroup Driver为systemd
#屏蔽这一行
#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
#增加这一行
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --exec-opt native.cgroupdriver=systemd
这里为什么改,自行百度重启docker
systemctl daemon-reload && systemctl restart docker
查看状态
检查docker及相关命令
docker ps
docker version
docker images
service docker start 启动
service docker restart 重启
service docker stop 停止
systemctl status docker.service 状态