Help us understand the problem. What is going on with this article?

Dockerで各containerの初期ディスクサイズを拡張する

More than 3 years have passed since last update.

CentOS 7.0ホストのDocker 1.3.2で確認。

Dockerはデフォルトでは各コンテナに10GBの(仮想)ディスクを割り当てます。

Console
[hoge@docker ~]$ sudo docker run -it centos /bin/bash
[root@8e856a8f4666 /]# df -h
Filesystem                                                                                          Size  Used Avail Use% Mounted on
/dev/mapper/docker-8:19-134785216-8e856a8f46660e16e9ce6c1a73e937e9a7366d19bd3ac2a239324f8671642853  9.8G  260M  9.0G   3% /
tmpfs                                                                                               3.6G     0  3.6G   0% /dev
shm                                                                                                  64M     0   64M   0% /dev/shm
/dev/sdb3                                                                                           107G  8.1G   99G   8% /etc/hosts
tmpfs                                                                                               3.6G     0  3.6G   0% /run/secrets
tmpfs                                                                                               3.6G     0  3.6G   0% /proc/kcore


10GBでは足りない場合、docker daemonにオプションを与えて起動することでcontainerの基本ディスクサイズを大きくすることができます。ただし変更を反映させるには /var/lib/dockerのクリアが必要です。(既存のコンテナやイメージは消えます)

20GBにしたい場合、/var/lib/dockerクリア後以下のように--storage-opt オプションを追加して起動します。

rm -rf /var/lib/docker
docker -d --storage-opt dm.basesize=20G

CentOS 6などsystemdを使ってサービス起動している場合は /etc/sysconfig/docker に同じオプションを追加すればOK。

Console
# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS=--storage-opt dm.basesize=20G --selinux-enabled -H fd://

[hoge@docker ~]$ sudo service docker start
[hoge@docker ~]$ sudo docker run -it centos /bin/bash
[root@62a3ac2272da /]# df -h
Filesystem                                                                                          Size  Used Avail Use% Mounted on
/dev/mapper/docker-8:19-404124118-62a3ac2272da80c502fa19c10d5bf844859c3d6a63cf5157c391d4978d2352f8   20G  268M   19G   2% /

無事ディスクサイズが大きくなりました。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした