Home | Back
การแก้ปัญหา swap limit capabilities ใน Docker
Saturday, 11 October 2014
ในการสั่ง Docker run นั้น จะมีพารามิเตอร์ -m เพื่อกำหนด limit ของ memory ให้กับ Container นั้น โดยปกติ Kernel จะต้องรองรับ cgroup swap limit ด้วย แต่โดยปกติแล้ว Kernel จะไม่ได้กำหนดให้รองรับไว้แต่แรกทำให้เมื่อรัน Container แบบ limit memory แล้ว จะได้รับคำเตือนว่า “WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.” แต่เราสามารถแก้ไขได้ดังนี้ครับ
1. กำหนดให้ Kernel รองรับ cgroup swap limit
แก้ไขไฟล์ /etc/default/grub ดังนี้ครับ
File : /etc/default/grub
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
2. กำหนด config ของ grub ใหม่
จากนั้นให้ทำการปรับปรุง Grub ใหม่ดังนี้ครับ
$ grub-mkconfig -o /boot/grub/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-linux Found initrd image: /boot/initramfs-linux.img Found fallback initramfs image: /boot/initramfs-linux-fallback.img done
จากนั้น reboot เครื่องใหม่ ระบบ Docker ก็จะรองรับการ limit memory แล้วครับ