Introduction
实现 Run 命令版本的容器
Linux Proc 文件系统
Linux 下 /proc 挂载了一个 proc 文件系统,其包含了系统运行时的信息,这个文件系统是 Memory-only 的,linux 通过这个文件系统向其他工具提供了访问内核数据的接口。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| ❯ ls /proc 1 14 20 24 3940834 41162 933 ioports schedstat 10 140 20183 2450366 3941756 419342 952 irq scsi 1002 141 20184 24626 3974374 419343 955 kallsyms self 1016 142 20187 24797 3988521 442 962 kcore slabinfo 11 143 20188 24929 3988538 443 967 keys softirqs 1131714 145 20189 24939 3988558 6 acpi key-users stat 1154526 146 20190 24943 3994807 6443 buddyinfo kmsg swaps 1154569 15 2033894 26 4 694107 bus kpagecgroup sys 12 1522 20598 26308 400438 698 cgroups kpagecount sysrq-trigger 123 1528 20599 27 400441 699 cmdline kpageflags sysvipc 124 1529 21 27032 4012994 700 consoles loadavg thread-self 125 158 22 2720100 4013026 701 cpuinfo locks timer_list 126 16 224 28 4024940 702 crypto mdstat tty 127 162 225 29 4025287 70898 devices meminfo uptime 128 1657 226 297 4025309 719 diskstats misc version 129 1663 229035 3 4025395 735 dma modules version_signature 13 17 23 30 4025396 766854 driver mounts vmallocinfo 130 178 237656 31 4025425 766881 execdomains mtrr vmstat 131 18 237657 343 4025582 852 fb net zoneinfo 134 1803307 237685 344 4025583 860 filesystems pagetypeinfo 135 19580 239890 381047 4025596 889 fs partitions 138 19689 239915 381048 4055795 9 interrupts pressure 139 2 239916 393295 4056073 931 iomem sched_debug
❯ sudo ls /proc/237656 arch_status coredump_filter io mountstats patch_state smaps timers attr cpuset limits net personality smaps_rollup timerslack_ns autogroup cwd loginuid ns projid_map stack uid_map auxv environ map_files numa_maps root stat wchan cgroup exe maps oom_adj sched statm clear_refs fd mem oom_score schedstat status cmdline fdinfo mountinfo oom_score_adj sessionid syscall comm gid_map mounts pagemap setgroups task
|
/proc/N:N为PID
cmdline:启动命令
cwd:工作目录(是个符号链接)
environ:环境变量列表
exe:进程的可执行文件(符号链接)
fd:文件描述符
maps_files:内存映射
mem:进程所持有的内存,不可读
root:进程根目录(符号链接)
stat:进程状态
statm:进程使用的内存状态
status:进程状态信息(可读性更好)
/proc/self/ 链接到当前正在运行的进程