我正在尝试部署 docker 容器来使用 gitlab 运行程序执行一些测试,但是当我执行 docker-compose up 命令时,我得到以下输出:
admin@runners-test:~/runner-test$ sudo docker-compose up -d
Starting gitlab-runner ... error
ERROR: for gitlab-runner Cannot start service gitlab-runner: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: process_linux.go:458: setting cgroup config for procHooks process caused: can't load program: operation not permitted: unknown
ERROR: for gitlab-runner Cannot start service gitlab-runner: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: process_linux.go:458: setting cgroup config for procHooks process caused: can't load program: operation not permitted: unknown
ERROR: Encountered errors while bringing up the project.
Abd 这是journalctl 的输出:
Sep 23 07:23:24 runners-test dockerd[231]: time="2022-09-23T07:23:24.560275437Z" level=error msg="stream copy error: reading from a closed fifo"
Sep 23 07:23:24 runners-test dockerd[231]: time="2022-09-23T07:23:24.577270402Z" level=error msg="stream copy error: reading from a closed fifo"
Sep 23 07:23:24 runners-test dockerd[231]: time="2022-09-23T07:23:24.675282811Z" level=error msg="0cd3bbb779a947012c9059921f092b569eb088bb2fe0bf99a8ae3266ec43abbd cleanup: failed to delete container from containerd: no such container"
Sep 23 07:23:24 runners-test dockerd[231]: time="2022-09-23T07:23:24.675625496Z" level=error msg="Handler for POST /v1.25/containers/0cd3bbb779a947012c9059921f092b569eb088bb2fe0bf99a8ae3266ec43abbd/start returned error: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: process_linux.go:458: setting cgroup config for procHooks process caused: can't load program: operation not permitted: unknown"
还有 docker-compose 文件:
version: '3'
services:
gitlab-runner:
container_name: gitlab-runner
image: 'gitlab/gitlab-runner:latest'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./config:/etc/gitlab-runner
restart:
unless-stopped
我尝试提起的任何容器都会出现此错误,即使是做一个简单的
docker run hello-world
...
我也在 proxmox 论坛上查看了这篇post,但我不知道如何为 lxc 容器添加内核命令行参数,我一直在尝试编辑
/etc/default/grub
文件,但 update-grub 命令没有在 lxc 中无法按我想要的方式工作,我得到以下输出:
admin@runners-test:/$ sudo update-grub
[sudo] password for admin:
/usr/sbin/grub-probe: error: failed to get canonical path of `/dev/mapper/pve-vm--1010118--disk--0'.
我真的很困惑,所以欢迎任何形式的帮助:)谢谢!
当我最终发现(在 CentOS 上)更新可以解决问题时,我参考了许多其他链接。 所以:
yum update -y
reboot
重启后,系统重新上线,我继续运行我的 docker 容器,在本例中是 docker 注册表:
[root@server ~]# docker run -d --name registry registry:2
c40941bf42c853709bcca05bad4e8914df1f4932a355607f37b55f7e0ed01e60
[root@server ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
c40941bf42c8 registry:2 "/entrypoint.sh /e..." 3 seconds ago Up 2 seconds 5000/tcp
docker 容器启动正常。
所以,这里也是我查看的参考页面,我不需要像这个参考那样更改
/boot/boot.txt
中的任何内容,但这是很好的信息:
https://my-take-on.tech/2021/05/07/fix-docker-cgroup-errors-after-systemd-248-update/
还有这个,在我读完之后,它让我终于尝试做一个
yum update
来修复:
我遇到了这个问题。最终我发现这是由于容器内的docker太旧引起的。我的主机系统使用了旧的 docker 无法处理的 cgroups v2。将容器从 Debian 11 切换到 Debian 12 解决了我的问题。
我遇到了这个问题并重新启动服务器修复了它。