前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >k8s集群部署一(最新版docker安装) 顶

k8s集群部署一(最新版docker安装) 顶

作者头像
算法之名
发布2019-08-20 10:05:11
2.6K0
发布2019-08-20 10:05:11
举报
文章被收录于专栏:算法之名算法之名

因为这里面docker跟我们平常用的docker有点不同,需要好好过一遍(本人的三台服务器的IP跟上图不同,现在最新版本的docker为18.09.2)

首先安装docker

yum install docker

service docker start后

# docker info Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 1.13.1 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: journald Cgroup Driver: systemd Plugins: Volume: local Network: bridge host macvlan null overlay Swarm: inactive Runtimes: docker-runc runc Default Runtime: docker-runc Init Binary: /usr/libexec/docker/docker-init-current containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1) runc version: N/A (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f) init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574) Security Options: seccomp WARNING: You're not using the default seccomp profile Profile: /etc/docker/seccomp.json Kernel Version: 3.10.0-693.2.2.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 Number of Docker Hooks: 3 CPUs: 8 Total Memory: 15.51 GiB Name: iZwz96hara3twaymw4yt9sZ ID: CSGX:VQEF:6XN6:VKCY:WDAI:YK3F:MDM7:QIVJ:STV2:K62C:XHDN:DDAF Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Experimental: false Insecure Registries: 172.18.98.48:5000 127.0.0.0/8 Registry Mirrors: https://registry.docker-cn.com Live Restore Enabled: false Registries: docker.io (secure)

我们可以看到Server Version: 1.13.1这个版本并非我们所需要的,我们需要的是最新版

进入容器Hub服务控制台,中间有一个加速器。我们点击它之后,阿里云会为我们创建一个专属加速器地址。安装完成后编辑

vim /etc/docker/daemon.json

{ "registry-mirrors": ["https://n62k26ut.mirror.aliyuncs.com"] }

其中"registry-mirrors": ["https://n62k26ut.mirror.aliyuncs.com"]就是阿里云给我们的镜像加速器地址。

安装所需要的库

yum install -y yum-utils device-mapper-persistent lvm2

配置docker-ce源

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

此时查看

# ll /etc/yum.repos.d/ total 12 -rw-r--r-- 1 root root 675 Feb 14 11:07 CentOS-Base.repo -rw-r--r-- 1 root root 2424 Oct 25 01:22 docker-ce.repo -rw-r--r-- 1 root root 230 Feb 14 11:07 epel.repo

此时可以看到多了docker-ce.repo

service docker stop

yum remove docker docker-common docker-selinux docker-engine 移除之前安装的docker

yum install docker-ce 重新安装docker-ce

安装成功后,重新service docker start

docker info

Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 18.09.2 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce runc version: 09c8266bf2fcf9519a651b04ae54c967b9ab86ec init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 3.10.0-693.2.2.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 8 Total Memory: 15.51GiB Name: iZwz96hara3twaymw4yt9sZ ID: CSGX:VQEF:6XN6:VKCY:WDAI:YK3F:MDM7:QIVJ:STV2:K62C:XHDN:DDAF Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false Product License: Community Engine

WARNING: bridge-nf-call-iptables is disabled WARNING: bridge-nf-call-ip6tables is disabled

我们可以看到Server Version: 18.09.2,已经是最新版

如果在service docker start报错

docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) Active: failed (Result: start-limit) since Thu 2019-02-14 15:31:41 CST; 52s ago Docs: https://docs.docker.com Process: 6989 ExecStart=/usr/bin/dockerd -H fd:// (code=exited, status=1/FAILURE) Main PID: 6989 (code=exited, status=1/FAILURE)

可以编辑docker.service

vim /lib/systemd/system/docker.service

将ExecStart=/usr/bin/dockerd -H fd://的-H fd://给注释掉

ExecStart=/usr/bin/dockerd #-H fd://

保存,退出

systemctl daemon-reload & systemctl start docker再启动后正常。

如果升级后,有之前的服务无法启动,并且报以下错误

Error response from daemon: Unknown runtime specified docker-runc

可以先docker ps -a查看该容器的id(以gitlab为例)

docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES feadb68c9e94 504ada597edc "/assets/wrapper" 7 months ago Exited (137) About an hour ago 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:10022->22/tcp gitlab

cd /var/lib/docker/containers [root@izwz9a7tvx688psgy738m4z containers]# ll total 4 drwx------ 6 root root 4096 Feb 14 17:03 feadb68c9e94e924e8923f6739bf875b672a39080f218748e61d37d3eed99d4b

我们可以看到有一个文件夹的前12的字符跟该容器id一致,进入该文件夹

[root@izwz9a7tvx688psgy738m4z containers]# cd feadb68c9e94e924e8923f6739bf875b672a39080f218748e61d37d3eed99d4b/ [root@izwz9a7tvx688psgy738m4z feadb68c9e94e924e8923f6739bf875b672a39080f218748e61d37d3eed99d4b]# ll total 64 drwx------ 2 root root 4096 Jul 6 2018 checkpoints -rw------- 1 root root 28128 Feb 14 17:03 config.v2.json -rw-r--r-- 1 root root 1419 Feb 14 17:03 hostconfig.json -rw-r--r-- 1 root root 13 Feb 14 17:03 hostname -rw-r--r-- 1 root root 177 Feb 14 17:03 hosts drwx------ 3 root root 4096 Feb 14 17:01 mounts -rw-r--r-- 1 root root 149 Feb 14 17:03 resolv.conf -rw-r--r-- 1 root root 71 Feb 14 17:03 resolv.conf.hash drwxr-xr-x 2 root root 4096 Sep 26 18:29 secrets drwx------ 2 root root 4096 Jul 6 2018 shm

编辑hostconfig.json

vim hostconfig.json

清空"Runtime":"docker-runc"后面的字符串,"Runtime":""

保存退出,并再次启动该容器就可以了

docker start gitlab

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档