TAIDONG - 2023年5月
type: channel
link: https://zhangtaidong.cn/2023/05/
description: TAIDONG's Blog
items: WG 常见Docker 无法启动解决方案
items: Centos 8安装Docker

WG 常见Docker 无法启动解决方案
type: item
date: 2023-05-24T20:12:00+08:00
description: 实践环境：CentOS81.Docker无法启动问题docker logs -f 6b56126963dc21cdc515d6c758f1d949c55f203d36542b27e360ddbc556ae80a 2022-06-15T05:34:33.902Z Server Listening on http://0.0.0.0:51821 2022-06-15T05:34:33.903Z WireGuard Loading configuration... 2022-06-15T05:34:33.905Z WireGuard Configuration loaded. 2022-06-15T05:34:33.905Z WireGuard Config saving... 2022-06-15T05:34:33.906Z WireGuard Config saved. $ wg-quick down wg0 $ wg-quick up wg0 Error: Command failed: wg-quick up wg0 [#] ip link add wg0 type wireguard [#] wg setconf wg0 /dev/fd/63 [#] ip -4 address add 10.8.0.1/24 dev wg0 [#] ip link set mtu 1420 up dev wg0 [#] iptables -t nat -A POSTROUTING -s 192.0.2.0/24 -o eth0 -j MASQUERADE; iptables -A INPUT -p udp -m udp --dport 51820 -j ACCEPT; iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; modprobe: can't change directory to '/lib/modules': No such file or directory modprobe: can't change directory to '/lib/modules': No such file or directory iptables v1.8.3 (legacy): can't initialize iptables table `nat': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded. [#] ip link delete dev wg0 at ChildProcess.exithandler (child_process.js:383:12) at ChildProcess.emit (events.js:400:28) at maybeClose (internal/child_process.js:1058:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5) { killed: false, code: 3, signal: null, cmd: 'wg-quick up wg0' }解决方案modprobe ip_tables && modprobe iptable-nat2.Upgrade Linux Kernel of CentOS 8dnf -y updateuname -rdnf install -y https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpmrpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org dnf makecachednf --disablerepo="*" --enablerepo="elrepo-kernel" list available | grep kernel-mldnf --enablerepo="elrepo-kernel" install -y kernel-mlreboot uname -r

Centos 8安装Docker
type: item
date: 2023-05-24T17:26:00+08:00
description: centos 8安装docker1、御载以前的版本yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate dokcer-logrotate docker-engin御载docker-ce（ce代表社区版）yum remove docker-ce docker-ce-cli containerd.io删除docker资源rm -rf /var/lib/docker2、安装依赖包yum install -y yum-utils3、设置镜仓库（默认是国外仓库，下载非常慢）yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo4、更新yumyum makecache5、安装dockeryum install docker-ce docker-ce-cli containerd.io如果不想安装最新版本的docker，想安装指定版本，可以这样：先查询出docker有哪些版本yum list docker-ce --showduplicates | sort -r安装指定版本sudo yum install docker-ce-<version_string> docker-ce-cli-<version_string> containerd.io比如，安装18.09.1版本：sudo yum install docker-ce-18.09.1 docker-ce-cli-18.09.1 containerd.io6、启动dockersudo systemctl start docker查看是否启动成功docker version7、开机自动启动dockersystemctl enable dockerDocker官方的一键安装命令，适用于CentOS / Debian / Ubuntu系统curl -s https://get.docker.com/ | sh 或 curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh