Centos8安装docker18.xx.x

编程

# 添加docker用户, 并把当前用户添加到docker组内, 是为了当前用户拥有操作docker的权限

sudo useradd -m docker

sudo usermod -a -G docker k8s

# 关闭防火墙

sudo systemctl stop firewalld

sudo systemctl disable firewalld

# 修改iptables

sudo iptables -P FORWARD ACCEPT

sudo vim /etc/rc.local 添加 iptables -P FORWARD ACCEPT

# 下载解压docker

cd /opt

sudo wget https://download.docker.com/linux/static/stable/x86_64/docker-18.09.9.tgz

sudo tar xvf docker-18.09.9.tgz

sudo chown -R root:docker docker

# 创建systemd unit文件

cd /opt/docker

cat > docker.service <<"EOF"

[Unit]

Description=Docker Application Container Engine

Documentation=http://docs.docker.io

[Service]

WorkingDirectory=/opt/docker

Environment="PATH=/opt/docker:/bin:/sbin:/usr/bin:/usr/sbin"

EnvironmentFile=-/run/flannel/docker

ExecStart=/opt/docker/dockerd $DOCKER_NETWORK_OPTIONS

ExecReload=/bin/kill -s HUP $MAINPID

Restart=on-failure

RestartSec=5

LimitNOFILE=infinity

LimitNPROC=infinity

LimitCORE=infinity

Delegate=yes

KillMode=process

[Install]

WantedBy=multi-user.target

EOF

# 复制docker.service

sudo cp docker.service /etc/systemd/system/

# 启动docker服务

sudo systemctl daemon-reload

sudo systemctl enable docker

sudo systemctl restart docker

# 修改docker.sock权限

sudo chown root:docker /var/run/docker.sock

以上是 Centos8安装docker18.xx.x 的全部内容, 来源链接: utcz.com/z/513841.html

回到顶部