k8s集羣部署一(最新版docker安裝)

由於這裏面docker跟咱們日常用的docker有點不一樣,須要好好過一遍(本人的三臺服務器的IP跟上圖不一樣,如今最新版本的docker爲18.09.2)linux

首先安裝dockergit

yum install dockerdocker

service docker start後json

# 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)vim

咱們能夠看到Server Version: 1.13.1這個版本並不是咱們所須要的,咱們須要的是最新版centos

進入容器Hub服務控制檯,中間有一個加速器。咱們點擊它以後,阿里雲會爲咱們建立一個專屬加速器地址。安裝完成後編輯服務器

vim /etc/docker/daemon.jsonapp

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

其中"registry-mirrors": ["https://n62k26ut.mirror.aliyuncs.com"]就是阿里雲給咱們的鏡像加速器地址。gitlab

安裝所須要的庫

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

相關文章
相關標籤/搜索