1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Docker on CentOS7で特定コンテナの容量制限を柔軟に行ってみた

Last updated at Posted at 2019-04-07

Dockerで容量制限を柔軟に変更することができます。

ベースサイズよりも大きい容量に設定することができます。
ですので、例えば0.1Gをbase sizeとしてそれを拡大すれば、事実上自由に大きさを調整できるというわけです。

image.png

##Dockerインストール
https://qiita.com/inakadegaebal/items/be9fecce813cebec5986

##Storage Driverが overlayfs + xfs であるか確認

[root@localhost ~]# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 18.09.4
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: true
(略)

##サイズを指定してみて実行(成功)

[root@localhost ~]# docker run --storage-opt size=50g -t -i ubuntu /bin/bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
898c46f3b1a1: Pull complete 
63366dfa0a50: Pull complete 
041d4cd74a92: Pull complete 
6e1bee0f8701: Pull complete 
Digest: sha256:017eef0b616011647b269b5c65826e2e2ebddbe5d1f8c1e56b3599fb14fabec8
Status: Downloaded newer image for ubuntu:latest
root@d4b78fb73127:/# df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay          47G  1.5G   46G   4% /
tmpfs            64M     0   64M   0% /dev
tmpfs           910M     0  910M   0% /sys/fs/cgroup
/dev/sda3        47G  1.5G   46G   4% /etc/hosts
shm              64M     0   64M   0% /dev/shm
tmpfs           910M     0  910M   0% /proc/asound
tmpfs           910M     0  910M   0% /proc/acpi
tmpfs           910M     0  910M   0% /proc/scsi
tmpfs           910M     0  910M   0% /sys/firmware
root@d4b78fb73127:/# 

##場合によっては

sudo vi /etc/default/grub

GRUB_CMDLINE_LINUX= に「 rootflags=uquota,gquota,pquota 」を追記してください。

BIOSの場合
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo reboot

で適用できた

#See Also
https://qiita.com/haniokasai/items/2b7a1889e4930b7682c9

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?