项目地址: https://github.com/lxc/lxcfs
yum install fuse fuse-lib fuse-devel libtool
git clone git://github.com/lxc/lxcfs
cd lxcfs
./bootstrap.sh
./configure
make
make install
安装完成后,我们可以在前台启动测试下:
mkdir -p /var/lib/lxcfs # 先创建下目录
lxcfs /var/lib/lxcfs # 即可在前台启动
没问题后,建议使用systemd去控制运行。 具体启动脚本如下:
cat /lib/systemd/system/lxcfs.service
Unit
Description=FUSE filesystem for LXC
ConditionVirtualization=!container
Before=lxc.service
Documentation=man:lxcfs(1)
Service
ExecStart=/usr/local/bin/lxcfs /var/lib/lxcfs/
KillMode=process
Restart=on-failure
ExecStopPost=/usr/bin/fusermount -u /var/lib/lxcfs
Delegate=yes
Install
WantedBy=multi-user.target
chmod +x lxcfs.service
systemctl enable lxcfs.service
systemctl start lxcfs.service
docker run --rm --name unlimited-pod -ti --memory 256m --memory-swappiness 0 ubuntu:18.04 /bin/bash
docker run --rm --name limited-pod -ti --memory 256m --memory-swappiness 0 --cpus=2 \
-v /var/lib/lxcfs/proc/cpuinfo:/proc/cpuinfo:rw \
-v /var/lib/lxcfs/proc/diskstats:/proc/diskstats:rw \
-v /var/lib/lxcfs/proc/meminfo:/proc/meminfo:rw \
-v /var/lib/lxcfs/proc/stat:/proc/stat:rw \
-v /var/lib/lxcfs/proc/swaps:/proc/swaps:rw \
-v /var/lib/lxcfs/proc/uptime:/proc/uptime:rw \
ubuntu:18.04 /bin/bash
# 或者用下面的这种写法:
docker run --rm --name limited-pod -ti --memory 256m --memory-swappiness 0 --cpu-period=100000 --cpu-quota=200000 \
-v /var/lib/lxcfs/proc/cpuinfo:/proc/cpuinfo:rw \
-v /var/lib/lxcfs/proc/diskstats:/proc/diskstats:rw \
-v /var/lib/lxcfs/proc/meminfo:/proc/meminfo:rw \
-v /var/lib/lxcfs/proc/stat:/proc/stat:rw \
-v /var/lib/lxcfs/proc/swaps:/proc/swaps:rw \
-v /var/lib/lxcfs/proc/uptime:/proc/uptime:rw \
ubuntu:18.04 /bin/bash
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。