Posted at

CoreOSでdockerのbasesizeをかえる。

devicemapperのみ利用可能、overlay2 では使えないと思う。


下準備

/var/lib/docker

を消す(データが消える)


cloud init


cloud-config.ymlを作る

core20190325 core # vi cloud-config.yml


#cloud-config

coreos:
units:
- name: docker.service
drop-ins:
- name: 10-storage-opt.conf
content: |
[Service]
Environment="DOCKER_OPTS=--storage-opt dm.basesize=1G"
command: start


読み込む

core20190325 core # coreos-cloudinit -from-file=./cloud-config.yml

あるいは

ls /etc/systemd/system/docker.service.d/

vi その中にあるファイル(e.g.10-devicemapper-storage-driver.conf)
[Service]
Environment="DOCKER_OPTS= --storage-opt=dm.basesize=1G"


リロード

core20190325 core # systemctl daemon-reload

core20190325 core # systemctl stop docker


たまに消さなくても動作しそうです。

core20190325 core # rm -rf /var/lib/docker

core20190325 core # systemctl start docker
core20190325 core # docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 18.06.1-ce
Storage Driver: devicemapper
Pool Name: docker-8:9-1042461-pool
Pool Blocksize: 65.54kB
Base Device Size: 1.074GB
Backing Filesystem: xfs


Ref

https://qiita.com/python_spameggs/items/66f6bbe4b97be55f8b65

https://coreos.com/os/docs/latest/customizing-docker.html


See Also

https://qiita.com/haniokasai/items/2b7a1889e4930b7682c9