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

fd53ecf2bfbf5b9dfd2c94006c938bac657.jpg

f1d2f6d35fbd164c1c6f372b7777ae0b666.jpg

因为这里面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

转载于:https://my.oschina.net/u/3768341/blog/3010107

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值