ããã¯ããªã«ãããããŠæžãããã®ïŒ
䜿çšããŠããLinuxç°å¢ã®cgroupãv1ãªã®ãv2ãªã®ãã確èªããã«ã¯ïŒãšããããšã§ã
Kubernetesã®ããã¥ã¡ã³ãã«èŠåãæ¹ãæžãããŠããã®ã§ãè©ŠããŠã¿ãããšã«ããŸããã
cgroup v1ãšv2
Linuxã§ã¯ãããã»ã¹ãã°ã«ãŒãã«åããŠç®¡çããæ©èœã䜿ã£ãŠãããã»ã¹ã«å²ãåœãŠããªãœãŒã¹ãå¶éããŠããŸãã
ãããcgroupã§ãã
cgroupã«ã¯v1ãšv2ã®2ã€ããããŸãã
Control Groups — The Linux Kernel documentation
Control Group v2 — The Linux Kernel documentation
cgroupã䜿çšããããšã§ãå²ãåœãŠããªãœãŒã¹ãšããŠCPUãã¡ã¢ãªãŒãIOãå¶åŸ¡ã§ããŸãã
ããã§ãLinuxç°å¢ã§ã¯ã©ã¡ããã®ããŒãžã§ã³ã䜿ãããŠããããšã«ãªããŸããããã®èŠåãæ¹ã¯ã©ããããïŒãšããããšã§ã
çãã¯Kubernetesã®cgroup v2ã«é¢ããããã¥ã¡ã³ãã«æžãããŠããŸããã
ãã¡ãã§ããã
About cgroup v2 / Identify the cgroup version on Linux Nodes
以äžã®ã³ãã³ãã§ç¢ºèªã§ããããã§ãã
$ stat -fc %T /sys/fs/cgroup/
ãã®ã³ãã³ãã®åºåçµæãcgroup2fs
ã ãšcgroup v2ãtmpfs
ã ãšcgroup v1ã ããã§ãã
ãŸãããã®ããŒãžå ã«cgroup v2ã®èŠæ±äºé ãšäž»ãªLinuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã®cgroup v2ã®å¯Ÿå¿ãæžãããŠããŸããã
- About cgroup v2 / Using cgroup v2 / Requirements
- About cgroup v2 / Using cgroup v2 / Linux Distribution cgroup v2 support
cgroup v2ã®èŠæ±äºé ã¯ã以äžã§ãã
- OSãã£ã¹ããªãã¥ãŒã·ã§ã³ã§cgroup v2ãæå¹ã«ãªã£ãŠããããš
- Linuxã«ãŒãã«ã5.8以éã§ããããš
- ã³ã³ããã©ã³ã¿ã€ã ãcgroup v2ããµããŒãããŠããããš
- containerd v1.4以é
- cri-o v1.20以é
äž»èŠãªLinuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã®cgroup v2ã®å¯Ÿå¿ç¶æ³ã¯ã以äžã®éãã§ãã
- Container Optimized OS M97以é
- Ubuntu Linux 21.10以é
- æšå¥šã¯22.04以é
- Debian GNU/Linux 11 bullseye以é
- Fedora 31以é
- Arch Linux April 2021以é
- RHELããã³RHELäºæãã£ã¹ããªãã¥ãŒã·ã§ã³ã®9以é
ãã®æç¹ã§äœ¿ãLinuxãã£ã¹ããªãã¥ãŒã·ã§ã³ãšãã®ããŒãžã§ã³ã§ã ãããçãã¯åºãã®ã§ãããä»åã¯ãããæ瀺çã«ç¢ºèªããŠã¿ãããš
æããŸãã
察象ã«ã¯ãUbuntu Linux 22.04 LTSãš20.04 LTSã䜿ãããšã«ããŸãã
確èªã¯ãcgroup v2 â cgroup v1ã®é ã§è¡ããŸãã
ç°å¢
ä»åã®ç°å¢ã¯ããã¡ãã
Ubuntu Linux 22.04 LTSã
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy $ uname -srvmpio Linux 5.15.0-83-generic #92-Ubuntu SMP Mon Aug 14 09:30:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux $ docker version Client: Docker Engine - Community Version: 24.0.6 API version: 1.43 Go version: go1.20.7 Git commit: ed223bc Built: Mon Sep 4 12:31:44 2023 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 24.0.6 API version: 1.43 (minimum version 1.12) Go version: go1.20.7 Git commit: 1a79695 Built: Mon Sep 4 12:31:44 2023 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.22 GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca runc: Version: 1.1.8 GitCommit: v1.1.8-0-g82f18fe docker-init: Version: 0.19.0 GitCommit: de40ad0
Ubuntu Linux 20.04 TLSã
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.6 LTS Release: 20.04 Codename: focal $ uname -srvmpio Linux 5.4.0-162-generic #179-Ubuntu SMP Mon Aug 14 08:51:31 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux $ docker version Client: Docker Engine - Community Version: 24.0.6 API version: 1.43 Go version: go1.20.7 Git commit: ed223bc Built: Mon Sep 4 12:32:12 2023 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 24.0.6 API version: 1.43 (minimum version 1.12) Go version: go1.20.7 Git commit: 1a79695 Built: Mon Sep 4 12:32:12 2023 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.22 GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca runc: Version: 1.1.8 GitCommit: v1.1.8-0-g82f18fe docker-init: Version: 0.19.0 GitCommit: de40ad0
ããããã以äžã®Vagrant Boxã䜿ã£ãŠããŸãã
äžå¿ãDockerãŸã§å ¥ããŠãããŸããã
statã³ãã³ãã§cgroupã®ããŒãžã§ã³ã確èªãã
ããã§ã¯ãKubernetesã®ããã¥ã¡ã³ãã«ç¿ã£ãŠstatã³ãã³ãã§cgroupã®ããŒãžã§ã³ã確èªããŠã¿ãŸãããã
cgroup v2ã
$ stat -fc %T /sys/fs/cgroup/ cgroup2fs
cgroup v1ã
$ stat -fc %T /sys/fs/cgroup/ tmpfs
確ãã«ãcgroup v2ã§ã¯cgroup2fs
ãcgroup v1ã§ã¯tmpfs
ãšãªããŸããã
ããã§ãstatã³ãã³ãã®ãªãã·ã§ã³ã確èªããŠã¿ãŸãã
Ubuntu Manpage: stat - display file or file system status
statã¯ããã¡ã€ã«ãŸãã¯ãã¡ã€ã«ã·ã¹ãã ã®ç¶æ
ã衚瀺ããã³ãã³ãã§ãã
-f
ããã¡ã€ã«ã·ã¹ãã ã®ç¶æ
ã衚瀺ããããã«ãããªãã·ã§ã³ã§ïŒéåžžã¯ãã¡ã€ã«ã®ç¶æ
ã衚瀺ïŒã-c
ã¯åºåãæå®ã®æžåŒã«ãã
ãªãã·ã§ã³ã§ãã
%T
ã¯å¯Ÿè±¡ããã£ã©ã¯ã¿ãŒïŒãããã¯ããã€ã¹ã®ã¹ãã·ã£ã«ãã¡ã€ã«ã®å Žåããã€ããŒããã€ã¹çªå·ã衚瀺ããŸãã
cgroupã¯ãsysfså ã«ã³ã³ãããŒã©ãŒãããŠã³ãããããã§ããã
sysfs - _The_ filesystem for exporting kernel objects — The Linux Kernel documentation
- Control Group v2 / Controllers
- cgroup v1ã¯ã Control Groups version 1 — The Linux Kernel documentation å ã®åããŒãžãåç §
cgroup v2ã¯ãcgroup2ãšããŠããŠã³ãããŸãã
# mount -t cgroup2 none $MOUNT_POINT
Control Group v2 / Basic Operations / Mounting
cgroup v1ã¯ãtmpfsãšããŠããŠã³ãããŸãã
1) mount -t tmpfs cgroup_root /sys/fs/cgroup 2) mkdir /sys/fs/cgroup/cpuset 3) mount -t cgroup -ocpuset cpuset /sys/fs/cgroup/cpuset 4) Create the new cgroup by doing mkdir's and write's (or echo's) in the /sys/fs/cgroup/cpuset virtual file system. 5) Start a task that will be the "founding father" of the new job. 6) Attach that task to the new cgroup by writing its PID to the /sys/fs/cgroup/cpuset tasks file for that cgroup. 7) fork, exec or clone the job tasks from this founding father task.
Control Groups / Control Groups / How do I use cgroups ?
cgroup v2ãv1ããããã§/sys/fs/cgroup/
å
ãèŠããšããããªæãã«ãªã£ãŠããŸãã
cgroup v2ã
$ tree -L 1 /sys/fs/cgroup/ /sys/fs/cgroup/ âââ cgroup.controllers âââ cgroup.max.depth âââ cgroup.max.descendants âââ cgroup.procs âââ cgroup.stat âââ cgroup.subtree_control âââ cgroup.threads âââ cpu.pressure âââ cpu.stat âââ cpuset.cpus.effective âââ cpuset.mems.effective âââ dev-hugepages.mount âââ dev-mqueue.mount âââ init.scope âââ io.cost.model âââ io.cost.qos âââ io.pressure âââ io.prio.class âââ io.stat âââ memory.numa_stat âââ memory.pressure âââ memory.stat âââ misc.capacity âââ proc-sys-fs-binfmt_misc.mount âââ sys-fs-fuse-connections.mount âââ sys-kernel-config.mount âââ sys-kernel-debug.mount âââ sys-kernel-tracing.mount âââ system.slice âââ user.slice 10 directories, 20 files
cgroup v1ã
$ tree -L 1 /sys/fs/cgroup/ /sys/fs/cgroup/ âââ blkio âââ cpu -> cpu,cpuacct âââ cpu,cpuacct âââ cpuacct -> cpu,cpuacct âââ cpuset âââ devices âââ freezer âââ hugetlb âââ memory âââ net_cls -> net_cls,net_prio âââ net_cls,net_prio âââ net_prio -> net_cls,net_prio âââ perf_event âââ pids âââ rdma âââ systemd âââ unified 17 directories, 0 files
ããããcgroupã®ã³ã³ãããŒã©ãŒã§ããã
以éãããå°ãéãè§åºŠã§æ å ±ãèŠãŠãã£ãŠã¿ãŸãã
mountã³ãã³ãã§èŠãŠã¿ã
cgroupã®ã³ã³ãããŒã©ãŒã¯sysfsãã¡ã€ã«ã·ã¹ãã äžã§åäœããŠãããããªã®ã§ãmountã³ãã³ãã§ã確èªã§ãããã§ãã
cgroup v2ã
$ mount | grep cgroup cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
cgroup v1ã
$ mount | grep cgroup tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755) cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate) cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd) cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb) cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio) cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory) cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids) cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct) cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event) cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset) cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma) cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio) cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices) cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup v2ã§ã¯ãéå±€ã¯åäžã«ãªããŸãã
Unlike v1, cgroup v2 has only single hierarchy.
Control Group v2 / Basic Operations / Mounting
å¥è§£ã/proc/self/mountinfo
ããã
cgroup v2ã
$ cat /proc/self/mountinfo | grep cgroup 35 25 0:30 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime shared:9 - cgroup2 cgroup2 rw,nsdelegate,memory_recursiveprot
cgroup v1ã
$ cat /proc/self/mountinfo | grep cgroup 36 26 0:30 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:9 - tmpfs tmpfs ro,mode=755 37 36 0:31 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime shared:10 - cgroup2 cgroup2 rw,nsdelegate 38 36 0:32 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:11 - cgroup cgroup rw,xattr,name=systemd 41 36 0:35 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,hugetlb 42 36 0:36 / /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,net_cls,net_prio 43 36 0:37 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,memory 44 36 0:38 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,pids 45 36 0:39 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,cpu,cpuacct 46 36 0:40 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:20 - cgroup cgroup rw,perf_event 47 36 0:41 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:21 - cgroup cgroup rw,cpuset 48 36 0:42 / /sys/fs/cgroup/rdma rw,nosuid,nodev,noexec,relatime shared:22 - cgroup cgroup rw,rdma 49 36 0:43 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:23 - cgroup cgroup rw,blkio 50 36 0:44 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:24 - cgroup cgroup rw,devices 51 36 0:45 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:25 - cgroup cgroup rw,freezer
ã³ã³ããå ã§ãèŠãŠã¿ãŸãããã
cgroup v2ã
$ docker container run -it --rm ubuntu:22.04 cat /proc/self/mountinfo | grep cgroup 618 617 0:30 / /sys/fs/cgroup ro,nosuid,nodev,noexec,relatime - cgroup2 cgroup rw,nsdelegate,memory_recursiveprot
cgroup v1ã
$ docker container run -it --rm ubuntu:20.04 cat /proc/self/mountinfo | grep cgroup 702 701 0:61 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755 703 702 0:32 /docker/e71d4f44ee79dd9e2704f4e7131c5db6b5268eb137db847153b29b09c79d04f5 /sys/fs/cgroup/systemd ro,nosuid,nodev,noexec,relatime master:11 - cgroup cgroup rw,xattr,name=systemd 704 702 0:35 /docker/e71d4f44ee79dd9e2704f4e7131c5db6b5268eb137db847153b29b09c79d04f5 /sys/fs/cgroup/hugetlb ro,nosuid,nodev,noexec,relatime master:15 - cgroup cgroup rw,hugetlb 705 702 0:36 /docker/e71d4f44ee79dd9e2704f4e7131c5db6b5268eb137db847153b29b09c79d04f5 /sys/fs/cgroup/net_cls,net_prio ro,nosuid,nodev,noexec,relatime master:16 - cgroup cgroup rw,net_cls,net_prio 706 702 0:37 /docker/e71d4f44ee79dd9e2704f4e7131c5db6b5268eb137db847153b29b09c79d04f5 /sys/fs/cgroup/memory ro,nosuid,nodev,noexec,relatime master:17 - cgroup cgroup rw,memory 707 702 0:38 /docker/e71d4f44ee79dd9e2704f4e7131c5db6b5268eb137db847153b29b09c79d04f5 /sys/fs/cgroup/pids ro,nosuid,nodev,noexec,relatime master:18 - cgroup cgroup rw,pids 708 702 0:39 /docker/e71d4f44ee79dd9e2704f4e7131c5db6b5268eb137db847153b29b09c79d04f5 /sys/fs/cgroup/cpu,cpuacct ro,nosuid,nodev,noexec,relatime master:19 - cgroup cgroup rw,cpu,cpuacct 709 702 0:40 /docker/e71d4f44ee79dd9e2704f4e7131c5db6b5268eb137db847153b29b09c79d04f5 /sys/fs/cgroup/perf_event ro,nosuid,nodev,noexec,relatime master:20 - cgroup cgroup rw,perf_event 710 702 0:41 /docker/e71d4f44ee79dd9e2704f4e7131c5db6b5268eb137db847153b29b09c79d04f5 /sys/fs/cgroup/cpuset ro,nosuid,nodev,noexec,relatime master:21 - cgroup cgroup rw,cpuset 711 702 0:42 /docker/e71d4f44ee79dd9e2704f4e7131c5db6b5268eb137db847153b29b09c79d04f5 /sys/fs/cgroup/rdma ro,nosuid,nodev,noexec,relatime master:22 - cgroup cgroup rw,rdma 712 702 0:43 /docker/e71d4f44ee79dd9e2704f4e7131c5db6b5268eb137db847153b29b09c79d04f5 /sys/fs/cgroup/blkio ro,nosuid,nodev,noexec,relatime master:23 - cgroup cgroup rw,blkio 713 702 0:44 /docker/e71d4f44ee79dd9e2704f4e7131c5db6b5268eb137db847153b29b09c79d04f5 /sys/fs/cgroup/devices ro,nosuid,nodev,noexec,relatime master:24 - cgroup cgroup rw,devices 714 702 0:45 /docker/e71d4f44ee79dd9e2704f4e7131c5db6b5268eb137db847153b29b09c79d04f5 /sys/fs/cgroup/freezer ro,nosuid,nodev,noexec,relatime master:25 - cgroup cgroup rw,freezer
/proc/[pid]/cgroupã§èŠãŠã¿ã
æåŸã«èªåèªèº«ãæå±ããcgroupã®æ
å ±ãã/proc/self/cgroup
ã§èŠãŠã¿ãŸãããã
cgroup v2ã
$ cat /proc/self/cgroup 0::/user.slice/user-1000.slice/session-4.scope
cgroup v1ã
$ cat /proc/self/cgroup 12:freezer:/ 11:devices:/user.slice 10:blkio:/user.slice 9:rdma:/ 8:cpuset:/ 7:perf_event:/ 6:cpu,cpuacct:/user.slice 5:pids:/user.slice/user-1000.slice/session-6.scope 4:memory:/user.slice/user-1000.slice/session-6.scope 3:net_cls,net_prio:/ 2:hugetlb:/ 1:name=systemd:/user.slice/user-1000.slice/session-6.scope 0::/user.slice/user-1000.slice/session-6.scope
ããã»ã¹ãæå±ããcgroupã¯ã/proc/[pid]/cgroup
ã§ç¢ºèªã§ããŸããèªããã»ã¹ã®å Žåã¯ã/proc/self/cgroup
ãšãªããŸãã
cgroupã®åå空éã¯ã/proc/[pid]/cgroup
ãã¡ã€ã«ãšcgroupãã¡ã€ã«ã·ã¹ãã ïŒv1ã®å Žåã¯tmpfsãã¡ã€ã«ã·ã¹ãã ïŒã§è¡šçŸãããããšã
æžãããŠããŸãã
- Control Group v2 / Namespace
- Control Groups / Usage Examples and Syntax / Mounting hierarchies by name
ã³ã³ããå ã§ç¢ºèªããŠã¿ãŸãããã
cgroup v2ã
$ docker container run -it --rm ubuntu:22.04 cat /proc/self/cgroup 0::/
cgroup v1ã
$ docker container run -it --rm ubuntu:20.04 cat /proc/self/cgroup 12:freezer:/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc 11:devices:/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc 10:blkio:/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc 9:rdma:/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc 8:cpuset:/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc 7:perf_event:/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc 6:cpu,cpuacct:/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc 5:pids:/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc 4:memory:/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc 3:net_cls,net_prio:/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc 2:hugetlb:/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc 1:name=systemd:/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc 0::/docker/149c401b108d6be632678c8325ae96dbf9a7aba8c413747b2e1d764c61a128bc
cgroup v1ã®/docker/
ã®åŸãã«èŠããŠããã®ã¯ãã³ã³ããã®idã§ããã
äœè«
cgroup v1ã®å Žåãèªåèªèº«ã®ã³ã³ããã®idã¯/proc/self/cgroup
ã/proc/self/mountinfo
ãèŠãã°ãããããšã«ãªããŸãã
ã§ã¯cgroup v2ã®å Žåã¯ãšãããšã/proc/self/mountinfo
ã®cgroupãšããŠããŠã³ãããŠããç®æ以å€ãèŠãã°ããããã§ãã
$ docker container run -it --rm ubuntu:22.04 cat /proc/self/mountinfo | grep docker 588 425 0:46 / / rw,relatime master:223 - overlay overlay rw,lowerdir=/var/lib/docker/overlay2/l/XZFSJBHY5DCBKZT3WS3UVIIMNL:/var/lib/docker/overlay2/l/EJEZWN23ZAMZZ2VSUXSWEOV3OX,upperdir=/var/lib/docker/overlay2/a6049ac9fab5259cdddbeb67d0b36f2f6313f09a07a4b79a70097d00ca4c4ce5/diff,workdir=/var/lib/docker/overlay2/a6049ac9fab5259cdddbeb67d0b36f2f6313f09a07a4b79a70097d00ca4c4ce5/work 621 588 253:0 /var/lib/docker/containers/d2454afd9c7b4c47b726c8f556e6f83b100a464b4f6440fe9f0c92fcb39c61ea/resolv.conf /etc/resolv.conf rw,relatime - ext4 /dev/mapper/ubuntu--vg-ubuntu--lv rw 622 588 253:0 /var/lib/docker/containers/d2454afd9c7b4c47b726c8f556e6f83b100a464b4f6440fe9f0c92fcb39c61ea/hostname /etc/hostname rw,relatime - ext4 /dev/mapper/ubuntu--vg-ubuntu--lv rw 623 588 253:0 /var/lib/docker/containers/d2454afd9c7b4c47b726c8f556e6f83b100a464b4f6440fe9f0c92fcb39c61ea/hosts /etc/hosts rw,relatime - ext4 /dev/mapper/ubuntu--vg-ubuntu--lv rw
ãããªãšããã§ããããã
ãããã«
䜿çšããŠããLinuxç°å¢ã®cgroupããv1ãªã®ãv2ãªã®ãã確èªããæ¹æ³ãã¡ãã£ãšèª¿ã¹ãŠã¿ãŸãããã¡ãã£ãšè±ç·ãããŠããŸããã©ã
ããŸãæ瀺çã«ç¢ºèªããæ©äŒã¯ãªãæ°ãããŸãããã³ã³ããã«é¢ããåšèŸºç¥èãèŠãŠãããæããªã®ã§ããŸã«ããããã®ãè¿œã£ãŠã¿ããš
é¢çœãã§ããã
/sys/fs/cgroup
ã/proc/self/cgroup
ã/proc/self/mountinfo
ã¯ã©ã³ã¿ã€ã ãã©ã€ãã©ãªãŒã®ã³ã³ãã察å¿ã§ãåºãŠããã®ã§ã
èŠããŠãããšãããããããŸããã
éå»ã«æžãããšã³ããªãŒã¯ããã®ãããã§ãã
JavaがDockerコンテナ内でどのようにCPU数、メモリサイズを取得しているのかを調べてみる - CLOVER🍀
Dockerコンテナ内で動作するNode.jsが認識するCPU数、メモリサイズ(ヒープサイズ除く)は、ホスト側のものになるという話 - CLOVER🍀