一键安装Docker 19.03.7

以CentOS7 为例,一键安装Docker 19.03.7


yum install -y bash-completion vim curl wget net-tools bind-utils iproute2 telnet lsof psmisc procps htop atop  zip unzip container-selinux socat psmisc nfs-utils yum-utils device-mapper-persistent-data lvm2


wget https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
wget https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-19.03.7-3.el7.x86_64.rpm
wget https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-19.03.7-3.el7.x86_64.rpm

rpm -ivh containerd.io-1.2.6-3.3.el7.x86_64.rpm
rpm -ivh docker-ce-cli-19.03.7-3.el7.x86_64.rpm
rpm -ivh docker-ce-19.03.7-3.el7.x86_64.rpm


modprobe bridge
cat <>/etc/sysctl.conf
net.ipv4.ip_forward = 1
net.ipv4.ip_local_port_range = 32768 65535
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-arptables = 1
EOF
sysctl -p




mkdir -p /etc/docker
cat < /etc/docker/daemon.json
{
    "hosts": [ "unix:///var/run/docker.sock" ],
    "mtu": 1450,
    "debug": false,
    "experimental": true,
    "metrics-addr": "0.0.0.0:1337",
    "selinux-enabled": false,
    "registry-mirrors": [
        "https://docker.mirrors.ustc.edu.cn",
        "https://2508xbaf.mirror.aliyuncs.com"
    ],
    "insecure-registries":[
        "gcr.io",
        "quay.io",
        "registry.cn-hangzhou.aliyuncs.com"
    ],
    "exec-opts": [ "native.cgroupdriver=cgroupfs" ],
    "exec-root": "/var/run/docker",
    "data-root": "/data0/docker/graph",
    "storage-driver": "overlay2",
    "storage-opts": [ "overlay2.override_kernel_check=true" ],
    "live-restore": true,
    "max-concurrent-downloads": 20,
    "max-concurrent-uploads": 5,
    "shutdown-timeout": 15,
    "oom-score-adjust": -999,
    "default-shm-size": "64M",
    "log-driver": "json-file",
    "log-level": "warn",
    "log-opts": {
      "max-size": "200m",
      "max-file": "10"
    },
    "default-address-pools":[{"base":"172.16.0.0/16","size":24}],
    "seccomp-profile": "",
    "no-new-privileges": false,
    "raw-logs": false
}
EOF


cat </usr/lib/systemd/system/docker.service;
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
ExecStart=/usr/bin/dockerd  --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process

[Install]
WantedBy=multi-user.target
EOF


systemctl daemon-reload
systemctl enable docker
systemctl restart docker
docker version

你可能感兴趣的:(一键安装Docker 19.03.7)