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) 时,遇到了与 iptablesnftables 相关的错误,提示无法初始化网络控制器。

解决方案

确认系统中 iptablesnftables 的配置和版本兼容性。我记得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-legacyupdate-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 , 但是这个依赖BPFBPF_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 时遇到的问题。

相关文章
|
5月前
|
Kubernetes Docker Python
Docker 与 Kubernetes 容器化部署核心技术及企业级应用实践全方案解析
本文详解Docker与Kubernetes容器化技术,涵盖概念原理、环境搭建、镜像构建、应用部署及监控扩展,助你掌握企业级容器化方案,提升应用开发与运维效率。
873 108
|
3月前
|
应用服务中间件 网络安全 nginx
手把手教你使用 Docker 部署 Nginx 教程
本文详解Nginx核心功能与Docker部署优势,涵盖镜像拉取、容器化部署(快速、挂载、Compose)、HTTPS配置及常见问题处理,助力高效搭建稳定Web服务。
1268 4
|
5月前
|
运维 Devops 持续交付
揭秘 Docker 自动部署神器 Websoft9:热门开源软件一键部署
在企业IT建设中,软件部署常面临效率低、易出错等问题。通过Docker与自动化工具,可实现高效、标准化和可追溯的部署流程,提升企业应用交付效率,降低运维门槛,助力中小企业实现自动化部署。
328 5
揭秘 Docker 自动部署神器 Websoft9:热门开源软件一键部署
|
4月前
|
JavaScript 算法 前端开发
【Docker项目实战】使用Docker部署paopao-ce微社区
【Docker项目实战】使用Docker部署paopao-ce微社区
404 84
【Docker项目实战】使用Docker部署paopao-ce微社区
|
5月前
|
运维 Cloud Native 开发者
Docker:现代化应用开发与部署的神器
Docker:现代化应用开发与部署的神器
256 101
|
5月前
|
设计模式 Linux 开发工具
Docker部署会吗?
本段内容主要介绍了Docker常用命令、Linux基础指令及日志查看方法,还涉及SpringMVC的执行流程、设计模式与注解,适合用于面试中技术能力的展示。
159 0
|
3月前
|
应用服务中间件 Linux nginx
在虚拟机Docker环境下部署Nginx的步骤。
以上就是在Docker环境下部署Nginx的步骤。需要注意,Docker和Nginix都有很多高级用法和细节需要掌握,以上只是一个基础入门级别的教程。如果你想要更深入地学习和使用它们,请参考官方文档或者其他专业书籍。
172 5
|
4月前
|
存储 Docker Python
docker 部署 sftp
本文介绍SFTP服务的部署与配置,包括users.conf用户配置规则、Docker容器运行命令及上传目录权限说明,重点解析atmoz/sftp镜像的chroot机制与子目录映射,确保用户登录后正确访问/upload目录,并提供Python脚本实现文件上传示例。
323 12
docker 部署 sftp
|
4月前
|
运维 Linux 数据库
基于 Docker 部署 n8n 指南,新手一看就会
本教程详解如何通过 Docker 快速部署开源自动化工具 n8n,适合新手快速上手。内容涵盖官方部署步骤、常见难点及第三方一键部署方案,助你高效搭建自动化工作流平台。
1369 6