我有一个 Python/Flask 应用程序 (Docker),它在 Docker (DinD) 进程中调用 Docker,但是当该调用发生时,我看到:
2023-07-07T02:21:28.733399366Z Traceback (most recent call last):
2023-07-07T02:21:28.733404074Z File "/home/meta/system/simulate.py", line 117, in simulate
2023-07-07T02:21:28.733408924Z job_container.start()
2023-07-07T02:21:28.733413666Z File "/usr/local/lib/python3.8/site-packages/docker/models/containers.py", line 404, in start
2023-07-07T02:21:28.733419036Z return self.client.api.start(self.id, **kwargs)
2023-07-07T02:21:28.733423792Z File "/usr/local/lib/python3.8/site-packages/docker/utils/decorators.py", line 19, in wrapped
2023-07-07T02:21:28.733428668Z return f(self, resource_id, *args, **kwargs)
2023-07-07T02:21:28.733433744Z File "/usr/local/lib/python3.8/site-packages/docker/api/container.py", line 1108, in start
2023-07-07T02:21:28.733438823Z self._raise_for_status(res)
2023-07-07T02:21:28.733443500Z File "/usr/local/lib/python3.8/site-packages/docker/api/client.py", line 261, in _raise_for_status
2023-07-07T02:21:28.733448503Z raise create_api_error_from_http_exception(e)
2023-07-07T02:21:28.733453223Z File "/usr/local/lib/python3.8/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
2023-07-07T02:21:28.733458407Z raise cls(e, response=response, explanation=explanation)
2023-07-07T02:21:28.733463125Z docker.errors.APIError: 500 Server Error: Internal Server Error ("cgroups: cgroup mountpoint does not exist: unknown")
我通过以下方式设置了 cgroup:
sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd
echo "GRUB_CMDLINE_LINUX=systemd.unified_cgroup_hierarchy=false" | sudo tee /etc/default/grub.d/cgroup.cfg
sudo update-grub
如果我运行lxc-checkconfig <container-id>
,我会得到:
LXC version 5.0.0~git2209-g5a7b9ce67
Kernel configuration not found at /proc/config.gz; searching...
Kernel configuration found at /boot/config-5.19.0-1025-aws
--- Namespaces ---
Namespaces: enabled
Utsname namespace: enabled
Ipc namespace: enabled
Pid namespace: enabled
User namespace: enabled
Network namespace: enabled
--- Control groups ---
Cgroups: enabled
Cgroup namespace: enabled
Cgroup v1 mount points:
/sys/fs/cgroup/systemd
Cgroup v2 mount points:
/sys/fs/cgroup
Cgroup v1 freezer controller: missing
Cgroup v1 clone_children flag: enabled
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: enabled
Cgroup cpuset: enabled
--- Misc ---
Veth pair device: enabled, loaded
Macvlan: enabled, not loaded
Vlan: enabled, not loaded
Bridges: enabled, loaded
Advanced netfilter: enabled, loaded
CONFIG_IP_NF_TARGET_MASQUERADE: enabled, not loaded
CONFIG_IP6_NF_TARGET_MASQUERADE: enabled, not loaded
CONFIG_NETFILTER_XT_TARGET_CHECKSUM: enabled, not loaded
CONFIG_NETFILTER_XT_MATCH_COMMENT: enabled, not loaded
FUSE (for use with lxcfs): enabled, not loaded
--- Checkpoint/Restore ---
checkpoint restore: enabled
CONFIG_FHANDLE: enabled
CONFIG_EVENTFD: enabled
CONFIG_EPOLL: enabled
CONFIG_UNIX_DIAG: enabled
CONFIG_INET_DIAG: enabled
CONFIG_PACKET_DIAG: enabled
CONFIG_NETLINK_DIAG: enabled
关于我缺少哪些配置来启用 cgroup 来减轻错误的想法?
服务器是:
Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy