5

LXC更新到Docker之后的存储部分修改

 9 months ago
source link: https://bajie.dev/posts/20231214-lxc_storage/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

LXC更新到Docker之后的存储部分修改

2023-12-14 1 分钟阅读

在k8s没有出来之前,我们用的就是LXC,古早版本了。

那时候是1:60的虚拟,一台物理机上跑60个LXC,居然这样运行了8年无异常,现在要升级一下了。

那时候的LXC,存储空间无法单独设定(缺省10G),cpu和mem的limit也有这样那样的问题。

进化到新版本的Docker后,存储部分也需要修改,我们采用overlay2:

docker info

...
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
...

缺省的就是overlay2和xfs

一、修改boot内核启动参数

vi /etc/default/grub

#加上rootflags=uquota,pquota
GRUB_CMDLINE_LINUX="console=tty0 crashkernel=auto net.ifnames=0 console=ttyS0 rootflags=uquota,pquota"

#更新
grub2-mkconfig -o /boot/grub2/grub.cfg

#重启
reboot

二、检验并启动容器

cat /proc/mounts  |grep vda
/dev/vda1 / xfs rw,relatime,attr2,inode64,usrquota,prjquota 0 0

有prjquota即可

按需启动容器,指定空间大小,size=2G

docker run --rm -dit --name=t36 --storage-opt size=2G --net macvlan0 --ip=172.18.31.36 alpine:latest ash

docker exec -it t36 ash
df -h
2020-08-24_104720.png

这样就可以单独限制容器的大小了。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK