1
+ #! /bin/bash
2
+ # # 自动yum安装Docker,Docker配置yum源 2020-05-31
3
+ # # 有问题反馈 https://aq2.cn/c/docker
4
+
5
+ # # robert yu
6
+ # # redhat 7
7
+
8
+ # #安装
9
+ # # yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
10
+ # # curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
11
+ # # curl -o /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
12
+ # # daemon.json k8s私有可以增加 "insecure-registries":["harbor.io", "k8s.gcr.io", "gcr.io", "quay.io"],
13
+ # # 卸载docker命令 yum remove -y docker-ce docker-common-*
14
+
15
+
16
+ yum-config-manager --add-repo https://mirrors.aliyun.com/repo/Centos-7.repo
17
+ yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
18
+ yum makecache fast
19
+ yum install -y yum-utils device-mapper-persistent-data lvm2 nfs-utils conntrack-tools
20
+ yum install -y docker-ce-18.09.8 docker-ce-cli-18.09.8
21
+
22
+
23
+ # #配置docker源
24
+ mkdir -p /etc/docker
25
+ if [[ -f /etc/docker/daemon.json ]] ; then
26
+ /usr/bin/cp /etc/docker/daemon.json /etc/docker/daemon.json.bak.` date " +%Y%m%d%H%M%S" `
27
+ fi
28
+ echo -e '
29
+ {
30
+ "storage-driver": "overlay2",
31
+ "storage-opts": [ "overlay2.override_kernel_check=true" ],
32
+ "registry-mirrors": ["https://4ux5p520.mirror.aliyuncs.com"],
33
+ "exec-opts": ["native.cgroupdriver=systemd"],
34
+ "data-root": "/data/docker",
35
+ "log-driver": "json-file",
36
+ "log-opts": {
37
+ "max-size": "100m"
38
+ }
39
+ }
40
+ ' > /etc/docker/daemon.json
41
+
42
+
43
+ # #启动
44
+ systemctl daemon-reload
45
+ systemctl enable docker
46
+ systemctl restart docker
47
+ docker version
0 commit comments