分享一个有用的项目 lxcfs

背景

在以前docker开发运维的时候,经常遇到一个情况,使用top/free命令的时候,把整个物理机的资源读出来了,lxcfx主要解决这个问题
https://github.com/lxc/lxcfs

Introduction

LXCFS is a small FUSE filesystem written with the intention of making Linux containers feel more like a virtual machine. It started as a side-project of LXC but is useable by any runtime.
LXCFS will take care that the information provided by crucial files in procfs such as:

/proc/cpuinfo
/proc/diskstats
/proc/meminfo
/proc/stat
/proc/swaps
/proc/uptime
/proc/slabinfo
/sys/devices/system/cpu
/sys/devices/system/cpu/online

(简单翻译一下,就是在执行上面命令的时候,显示虚拟机容器信息,而不是物理机信息)
are container aware such that the values displayed (e.g. in /proc/uptime) really reflect how long the container is running and not how long the host is running.

Prior to the implementation of cgroup namespaces by Serge Hallyn LXCFS also provided a container aware cgroupfs tree. It took care that the container only had access to cgroups underneath it's own cgroups and thus provided additional safety. For systems without support for cgroup namespaces LXCFS will still provide this feature but it is mostly considered deprecated.

posted @ 2022-07-11 11:32  致林  阅读(104)  评论(0编辑  收藏  举报