多种方式安装docker-ce和彻底卸载docker
安装docker-ce和彻底卸载docker
·
通过yum方式安装
###
yum -y install yum-utils
## 官方源
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
## 阿里云源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
## 查看docker的版本
yum list docker-ce --showduplicates | sort -r
## 安装指定版本的docker-ce
yum install docker-ce-20.10.3 docker-ce-cli-20.10.3
##
yum -y install docker-ce
##
systemctl start docker
安装K8S 需要配置的docker项
## 关闭swap
swapoff -a # 临时关闭
vim /etc/fstab # 永久关闭
## 关闭firewalld
systemctl disable firewalld
systemctl stop firewalld
二进制方式安装
## 官网
https://docs.docker.com/engine/install/binaries/#install-daemon-and-client-binaries-on-linux
## 下载
https://download.docker.com/linux/static/stable/x86_64/
##
cp * /usr/bin/
## 添加systemd的启动文件
## 启动
systemctl daemon-relaod
systemctl enable docker
vim docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3
# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
OOMScoreAdjust=-500
[Install]
WantedBy=multi-user.target
卸载
删除包
##
yum remove docker-ce*
## 删除文件夹
rm -rf /var/log/docker
rm -rf /var/lib/docker
删除网卡
ip link delete br-aea7d649de16
## 删除docker0 网卡
ip link delete docker0
删除iptables 规则
# 清除预设表filter中所有规则链中的规则
iptable -F
# 清除预设表filter中使用者自定链中的规则
iptables -X
## 清除NAT表规则,这个不建议去删
# $sudo iptables -F -t nat
# NAT表的显示
$sudo iptables -nL -t nat
更多推荐
已为社区贡献3条内容
所有评论(0)