Linux(31)Rockchip RK3568 Ubuntu22.04上部署 Docker: 问题与解决方案

简介: Linux(31)Rockchip RK3568 Ubuntu22.04上部署 Docker: 问题与解决方案

在尝试在基于 Rockchip RK3568 的设备上,运行 Ubuntu 22.04 rootfs 并安装 Docker 时,我遇到了一系列问题。本博客在总结这些问题及其解决方案,为遇到类似问题的兄弟提供参考,如果我后续有碰到其他Docker 问题也会在此更新补充。

# 我的设备环境:
root@btf:/$ docker --version
Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1
root@btf:/$ uname -a
Linux btf 4.19.219 #7 SMP Fri Mar 22 10:46:23 CST 2024 aarch64 aarch64 aarch64 GNU/Linux
root@btf:/$ cat /etc/issue
Ubuntu 22.04 LTS \n \l

1. Docker 服务无法启动

root@btf:/$ systemctl status docker
○ docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: inactive (dead)
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
root@btf:/$  dockerd --debug
INFO[2024-03-21T02:22:22.162686036Z] Starting up
DEBU[2024-03-21T02:22:22.165772744Z] Listener created for HTTP on unix (/var/run/docker.sock)
DEBU[2024-03-21T02:22:22.172340495Z] Golang's threads limit set to 14040
DEBU[2024-03-21T02:22:22.176763037Z] metrics API listening on /var/run/docker/metrics.sock
DEBU[2024-03-21T02:22:22.190162497Z] Using default logging driver json-file
DEBU[2024-03-21T02:22:22.193045622Z] No quota support for local volumes in /var/lib/docker/volumes: Filesystem does not support, or has not enabled quotas
DEBU[2024-03-21T02:22:22.196496331Z] processing event stream                       module=libcontainerd namespace=plugins.moby
INFO[2024-03-21T02:22:22.207613790Z] [graphdriver] trying configured driver: vfs
DEBU[2024-03-21T02:22:22.208240873Z] Initialized graph driver vfs
DEBU[2024-03-21T02:22:22.209004165Z] Max Concurrent Downloads: 3
DEBU[2024-03-21T02:22:22.209079415Z] Max Concurrent Uploads: 5
DEBU[2024-03-21T02:22:22.209110915Z] Max Download Attempts: 5
INFO[2024-03-21T02:22:22.209228749Z] Loading containers: start.
DEBU[2024-03-21T02:22:22.209483665Z] Option DefaultDriver: bridge
DEBU[2024-03-21T02:22:22.209541124Z] Option DefaultNetwork: bridge
DEBU[2024-03-21T02:22:22.209575249Z] Network Control Plane MTU: 1500
DEBU[2024-03-21T02:22:22.210205832Z] processing event stream                       module=libcontainerd namespace=moby
INFO[2024-03-21T02:22:22.230569417Z] unable to detect if iptables supports xlock: 'iptables --wait -L -n': `iptables/1.8.7 Failed to initialize nft: Protocol not supported`  error="exit status 1"
DEBU[2024-03-21T02:22:22.230980959Z] /usr/sbin/iptables, [-t filter -C FORWARD -j DOCKER-ISOLATION]
DEBU[2024-03-21T02:22:22.240452543Z] /usr/sbin/iptables, [-t nat -D PREROUTING -m addrtype --dst-type LOCAL -j DOCKER]
DEBU[2024-03-21T02:22:22.252465128Z] /usr/sbin/iptables, [-t nat -D OUTPUT -m addrtype --dst-type LOCAL ! --dst 127.0.0.0/8 -j DOCKER]
DEBU[2024-03-21T02:22:22.264647171Z] /usr/sbin/iptables, [-t nat -D OUTPUT -m addrtype --dst-type LOCAL -j DOCKER]
DEBU[2024-03-21T02:22:22.278666714Z] /usr/sbin/iptables, [-t nat -D PREROUTING]
DEBU[2024-03-21T02:22:22.288415965Z] /usr/sbin/iptables, [-t nat -D OUTPUT]
DEBU[2024-03-21T02:22:22.298152966Z] /usr/sbin/iptables, [-t nat -F DOCKER]
DEBU[2024-03-21T02:22:22.308048342Z] /usr/sbin/iptables, [-t nat -X DOCKER]
DEBU[2024-03-21T02:22:22.317894426Z] /usr/sbin/iptables, [-t filter -F DOCKER]
DEBU[2024-03-21T02:22:22.327381177Z] /usr/sbin/iptables, [-t filter -X DOCKER]
DEBU[2024-03-21T02:22:22.337190220Z] /usr/sbin/iptables, [-t filter -F DOCKER-ISOLATION-STAGE-1]
DEBU[2024-03-21T02:22:22.348203846Z] /usr/sbin/iptables, [-t filter -X DOCKER-ISOLATION-STAGE-1]
DEBU[2024-03-21T02:22:22.360229555Z] /usr/sbin/iptables, [-t filter -F DOCKER-ISOLATION-STAGE-2]
DEBU[2024-03-21T02:22:22.374536390Z] /usr/sbin/iptables, [-t filter -X DOCKER-ISOLATION-STAGE-2]
DEBU[2024-03-21T02:22:22.385013058Z] /usr/sbin/iptables, [-t filter -F DOCKER-ISOLATION]
DEBU[2024-03-21T02:22:22.394474434Z] /usr/sbin/iptables, [-t filter -X DOCKER-ISOLATION]
DEBU[2024-03-21T02:22:22.404029435Z] /usr/sbin/iptables, [-t nat -n -L DOCKER]
DEBU[2024-03-21T02:22:22.413653269Z] /usr/sbin/iptables, [-t nat -N DOCKER]
DEBU[2024-03-21T02:22:22.423293145Z] daemon configured with a 15 seconds minimum shutdown timeout
DEBU[2024-03-21T02:22:22.423441020Z] start clean shutdown of all containers with a 15 seconds timeout...
DEBU[2024-03-21T02:22:22.425325770Z] Cleaning up old mountid : start.
INFO[2024-03-21T02:22:22.425624437Z] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
DEBU[2024-03-21T02:22:22.426692812Z] Cleaning up old mountid : done.
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables/1.8.7 Failed to initialize nft: Protocol not supported
 (exit status 1)
问题描述

在尝试启动 Docker 服务时,通过 systemctl status docker 命令发现服务处于 inactive (dead) 状态,无法启动。

解决方案

系统已经配置为使用 iptables-nft 作为默认的 iptables 实现。Docker 启动时仍然提示 iptables/1.8.7 Failed to initialize nft: Protocol not supported 错误,就算在kernel打开了正确的 iptables 版本,但 Docker 与 nftables 的集成仍然存在问题。

CONFIG_NETFILTER=y
CONFIG_NETFILTER_ADVANCED=y
CONFIG_NF_CONNTRACK=y
CONFIG_NF_CONNTRACK_IPV4=y
CONFIG_NF_CONNTRACK_PROC_COMPAT=y
CONFIG_IP_NF_FILTER=y
CONFIG_IP_NF_TARGET_REJECT=y
CONFIG_IP_NF_NAT=y
CONFIG_IP_NF_TARGET_MASQUERADE=y
CONFIG_NF_NAT_IPV4=y
CONFIG_NF_NAT_MASQUERADE_IPV4=y
CONFIG_IP_NF_IPTABLES=y

2. Docker 守护进程启动问题

问题描述

在手动启动 Docker 守护进程 (dockerd) 时,遇到了与 iptables 和 nftables 相关的错误,提示无法初始化网络控制器。

解决方案

确认系统中 iptables 和 nftables 的配置和版本兼容性。我记得Ubuntu20.04 Docker 默认使用 iptables 管理网络规则,如果系统使用 nftables,可能需要进行额外的配置。

这个问题死活解决不了,因为我在RK3399 碰到过iptables的问题,后面是增加了许多kernel 宏才解决的,但是在RK3568失效了。 最后查到这篇帖子链接: ubuntu 22.04 iptables 运行失败解决方法

ubuntu 22.04默认使用nftables作为防火墙,而非iptables。

如果系统使用 nftables 作为默认的防火墙管理工具,可以尝试将 iptables 配置为使用 legacy 模式,通过执行 update-alternatives --set iptables /usr/sbin/iptables-legacy 和 update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy 命令来实现。

  • 重新启动 Docker 守护进程并检查是否能够成功启动。

3. 系统服务 nftables 启动失败

root@btf:/$ systemctl status nftables
× nftables.service - nftables
     Loaded: loaded (/lib/systemd/system/nftables.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2024-03-21 02:21:09 UTC; 3min 37s ago
       Docs: man:nft(8)
             http://wiki.nftables.org
    Process: 341 ExecStart=/usr/sbin/nft -f /etc/nftables.conf (code=exited, status=3)
   Main PID: 341 (code=exited, status=3)
        CPU: 82ms
3月 21 02:21:09 btf systemd[1]: Starting nftables...
3月 21 02:21:09 btf nft[341]: mnl.c:60: Unable to initialize Netlink sock…orted
3月 21 02:21:09 btf systemd[1]: nftables.service: Main process exited, co…ENTED
3月 21 02:21:09 btf systemd[1]: nftables.service: Failed with result 'exi…ode'.
3月 21 02:21:09 btf systemd[1]: Failed to start nftables.
Hint: Some lines were ellipsized, use -l to show in full.
问题描述

在检查 nftables 服务状态时,发现服务启动失败,提示 Failed to start nftables。

解决方案

检查 nftables 配置文件 /etc/nftables.conf 的语法是否正确。可以使用 nft list ruleset 命令来测试配置文件的语法。确认内核是否支持 nftables,并且所有必要的 nftables 模块都已加载。可以通过 lsmod | grep nft 命令来检查。如果问题依旧存在,查看系统日志 journalctl -u nftables 以获取更多错误信息再继续调试,反正就是宏没打开。

4. Docker 容器运行时错误

root@btf:/root$ docker run -it ubuntu:18.04 bash
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error setting cgroup config for procHooks process: bpf_prog_query(BPF_CGROUP_DEVICE) failed: function not implemented: unknown.
ERRO[0002] error waiting for container:
问题描述

尝试运行 Docker 容器时遇到 OCI runtime create failed 错误,提示与 cgroup 配置相关的问题,具体为 bpf_prog_query(BPF_CGROUP_DEVICE) failed: function not implemented。

解决方案

到这个问题基本上docker 已经能run、pull了,但是 Docker 容器运行时(如 runc)与宿主机的 cgroup 配置不兼容有关。这个问题折腾死我了 一度怀疑配置有问题,确保 Docker 和宿主机的 Linux内核cgroup 配置兼容。

容器初始化过程中,设置 cgroup 配置时遇到了问题,特别是与 BPF相关的功能。

最开始,我先用过check脚本检查docker环境,发现少打开了CGROUP_BPF ,打开之后也死活不行,最后看代码 kernel/init/Kconfig 里面有CGROUP_BPF , 但是这个依赖BPF和BPF_SYSCAL。

问题的根源在于内核配置中缺少了几个关键的 BPF 和 cgroup 相关的配置项。通过修改内核配置并启用以下选项,成功解决了问题:

  • CONFIG_CGROUP_BPF=y
  • CONFIG_BPF=y
  • CONFIG_BPF_SYSCALL=y

5. Docker 镜像拉取问题

btf@btf:/$ ls -l /var/run/docker.sock
ls: 无法访问 '/var/run/docker.sock': 没有那个文件或目录
btf@btf:/$ sudo docker pull ubuntu:18.04
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
问题描述

尝试使用 docker pull ubuntu:18.04 拉取 Ubuntu 镜像时,遇到连接 Docker 守护进程失败的问题,提示 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

解决方案

确认 Docker 服务是否正在运行:使用 systemctl status docker 检查 Docker 服务的状态。如果服务未运行,使用 systemctl start docker 启动服务。

检查当前用户是否有权限访问 Docker 守护进程。通常,需要将用户添加到 docker 组:sudo usermod -aG docker $USER。之后,重新登录或重启系统以应用更改。

确认 Docker 守护进程的 socket 文件 /var/run/docker.sock 存在且具有正确的权限设置。

最后我重复部署几次之后好像这个问题,是因为安装的docker-ce 而不是docker.io ?


希望这些详细的解决方案能够帮助有遇到相同问题的兄弟解决在 Rockchip RK3568 设备上部署 Docker 时遇到的问题。

相关文章
|
Ubuntu 编译器 计算机视觉
Ubuntu 20.04环境下无法找到#include<opencv/cv.h>文件 - 解决方案。
希望这些信息能帮助你解决遇到的问题。
698 10
|
Docker 容器
Docker网关冲突导致容器启动网络异常解决方案
当执行`docker-compose up`命令时,服务器网络可能因Docker创建新网桥导致IP段冲突而中断。原因是Docker默认的docker0网卡(172.17.0.1/16)与宿主机网络地址段重叠,引发路由异常。解决方法为修改docker0地址段,通过配置`/etc/docker/daemon.json`调整为非冲突段(如192.168.200.1/24),并重启服务。同时,在`docker-compose.yml`中指定网络模式为`bridge`,最后通过检查docker0地址、网络接口列表及测试容器启动验证修复效果。
2255 39
|
Ubuntu Linux UED
Ubuntu和Debian系统与Hat Linux系列的使用比较
所以,如果你想搞一个家用服务器,或者是个人使用,喜欢新鲜事物,那Ubuntu可能是你的最好选择。如果你需要一个在商业环境中经受住考验的系统,那Fedora或CentOS可能更符合你的口味。不过记住,CentOS现在是CentOS Stream,中途换马了,所以如果你是稳定性的极端追求者,可能得考虑一下这一变化。而Debian,则适合那些对稳定性需求极高,不太追求软件版本新旧的用户。
641 26
|
Ubuntu 搜索推荐 Linux
Ubuntu/Debian Hat系Linux的便捷操作指南
总的来说,虽然Ubuntu/Debian和Red Hat系列在操作方法上有所不同,但基本概念类似。掌握了包管理和服务管理,可以应对大多数常见的系统管理任务。同时,这两个系统都有丰富的在线资源可以查询,不管你在任务中遇到什么困难,搜索引擎都能帮你找到答案。这些基本技能能让你在Linux的世界里更加自如。
527 26
|
Ubuntu Linux Shell
Linux环境下VSCode快速安装终极指南:debian/ubuntu/linux平台通用
以上就是在Linux环境下安装VSCode的终极指南,抛开繁复的专业词汇,以平易近人的文字、形象生动的比喻让你轻松学会这一过程。别忘了,你的小伙伴VSCode已经在应用菜单里等你了!
3887 23
|
Ubuntu 机器人 开发者
Docker环境下的ROS Noetic:Ubuntu 20.04 系统下的解决方案
这就是在Docker环境下安装ROS Noetic在Ubuntu 20.04系统的一种简单方法,希望能对你有所帮助。
1496 16
|
关系型数据库 MySQL Linux
在Linux环境下备份Docker中的MySQL数据并传输到其他服务器以实现数据级别的容灾
以上就是在Linux环境下备份Docker中的MySQL数据并传输到其他服务器以实现数据级别的容灾的步骤。这个过程就像是一场接力赛,数据从MySQL数据库中接力棒一样传递到备份文件,再从备份文件传递到其他服务器,最后再传递回MySQL数据库。这样,即使在灾难发生时,我们也可以快速恢复数据,保证业务的正常运行。
783 28
|
Ubuntu 安全 Docker
Ubuntu下部署及操作Docker技巧
以上就是在Ubuntu下部署及操作Docker的具体步骤。但这只是冰山一角,Docker的魅力远不仅如此。你可以将其视为存放各种工具的小箱子,随时随地取用,极大地提升工作效率。你也可以私人订制,适应不同的开发环境,就像一个拥有各种口味冰淇淋的冰箱,满足各种各样的需求。好了,现在你已经掌握了基本的Docker运用技巧,快去尝试使用吧!记住,沉浸在探索中,你会找到无尽的乐趣和满满的收获。
704 23
|
Linux iOS开发 Docker
MyEMS开源系统安装之Linux/macOS上的DOcker
本指南详细介绍了如何在Linux/macOS上使用Docker部署MyEMS系统。主要内容包括:前置条件(如安装Docker、npm和MySQL),以及分步骤部署各个组件(如myems-api、myems-admin、myems-modbus-tcp等)。每个步骤涵盖源代码复制、环境配置、镜像构建、容器运行及日志管理等操作,并提供了多平台构建的支持。最后,指南还说明了默认端口和登录凭据,帮助用户快速启动并访问MyEMS的管理界面和Web界面。
641 1