Debian11(Bullseye)系统安装docker及启动失败问题解决 | 您所在的位置:网站首页 › win10启动nginx › Debian11(Bullseye)系统安装docker及启动失败问题解决 |
一、安装: 先卸载旧版本(没有也可以执行一遍): $ sudo apt-get remove docker docker-engine docker.io 1、添加使用 HTTPS 传输的软件包以及 CA 证书。(建议提前更换镜像源,官方的不稳定) 镜像源(不需要更换镜像源请忽略执行最后面两句安装https软件包及ca证书): cd /etc/apt mv sources.list sources.list.bak ##备份官方镜像源 echo " deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib deb https://mirrors.aliyun.com/debian-security/ bullseye-security main deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib " > sources.list ##创建新的sources.list文件并添加双引号中的内容 apt-get update ##更新一下 sudo apt-get update sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release 2、确保下载软件包的合法性,添加软件源的 GPG 密钥。 curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg3、在文件sources.list 中添加 Docker 软件源: echo \ "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/debian \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 4.1、使用脚本快速安装: curl -fsSL get.docker.com -o get-docker.sh ##下载脚本到当前目录下 sudo sh get-docker.sh --mirror Aliyun ##执行安装脚本 #启动 Docker sudo systemctl enable docker sudo systemctl start docker 4.2、使用apt命令安装 sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin 5、配置镜像加速 查看是否在 docker.service 文件中配置过镜像地址。 systemctl cat docker | grep '\-\-registry\-mirror' 有输出: systemctl cat docker ## 查看 ExecStart= 出现的位置,修改对应的文件内容,去掉 --registry-mirror 参数及其值,并按接下来的步骤进行配置。 没有任何输出: cd /etc/docker/ 在文件daemon.json 中写(如果文件不存在请新建该文件): { "registry-mirrors": [ "https://hub-mirror.c.163.com", "https://mirror.baidubce.com" ] }6、重新启动服务。 sudo systemctl daemon-reload sudo systemctl restart docker 二、启动docker失败: 尝试了查找错误:failed to mount overlay: no such device storage-driver=overlay 修改:配置 /etc/docker/daemon.json { "storage-driver": "overlay" (或overlay2) } 尝试查找错误:docker.service: Failed with result 'exit-code' 修改: 打开daemon.json sudo vim /etc/docker/daemon.json 改为 { "registry-mirrors": ["http://hub-mirror.c.163.com"] } 重启 sudo service docker restart 尝试了修改info文件夹,尝试了删除/etc/systemd/system/下的docker.service文件,尝试卸载重新安装但是docker-ce卸载就失败。前面都是查找问题方向错误。 最终: 发现问题: 启动docker: systemctl start docker提示: Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details. 按照提示输入命令systemctl status docker.service 或者 journalctl -xe查看具体错误内容 这里我使用journalctl -xe查到问题: root@maixsense:~# journalctl -xe ░░ A stop job for unit docker.service has finished. ░░ A stop job for unit docker.service has finished. May 18 09:35:17 maixsense systemd[1]: Failed to start Docker Application Contai> ░░ Subject: A start job for unit docker.service has failed ...finished. ... result is done. ...arting Docker Application Container Engine... ...service has begun execution ...as begun execution. ...: time="2023-05-18T09:35:17.358555629+08:00" level=info msg="Starting up" ...: time="2023-05-18T09:35:17.428078905+08:00" level=error msg="failed to mount o> ...: time="2023-05-18T09:35:17.428367156+08:00" level=error msg="exec: \"fuse-over> ...: time="2023-05-18T09:35:17.442004810+08:00" level=info msg="Loading containers> ...: time="2023-05-18T09:35:17.452457447+08:00" level=warning msg="Running modprob> ...: time="2023-05-18T09:35:17.475668859+08:00" level=info msg="unable to detect i> ...: time="2023-05-18T09:35:17.700487435+08:00" level=info msg="stopping event str> ...: failed to start daemon: Error initializing network controller: error obtainining network controller: error obtaining controller instance: failed to createAT chain DOCKER: iptables failed: iptables -t nat -N D OCKER: iptables v1.4.21: can't initialize iptables table `nat': Table does not exist (do you need to ins mod?) : (exit status 1) cker.service: Main process exited, code=exited, status=1/FAILURE 重点找error! 解决: 将iptables用iptables-legacy替换: sudo update-alternatives --set iptables /usr/sbin/iptables-legacy |
CopyRight 2018-2019 实验室设备网 版权所有 |