2

I have a docker container with jenkins (let it be container1) - it is standard container run only with --privileged flag.

As part of CI process I am running containers inside this containers (for integration tests and so on). Everything worked nice - but I have decided to commit this container and founded that it's image (the result of commit) virtual size is ~140 Gb! And folder /var/lib/docker on the host (sudo du -sh /var/lib/docker) show's me 152 Gb

I logged in my container by sudo docker exec -i -t container1 and completely removed everything inside /var/lib/docker in container. I also run sudo du -sh / inside container1 and it showed only 32 Gb (which is normal - it is android SDK and other stuff). I tried to commit this container again - but results are the same ~ 140 Gb. So may be docker on the host were not able to reduce container size? Is there an way to say docker on the host that the container is almost empty and need to be shrunk

My docker info on host is:

  1. Containers: 5
  2. Images: 65 Storage
  3. Driver: aufs
  4. Root Dir:/var/lib/docker/aufs
  5. Dirs: 75
  6. Execution Driver: native-0.2 Kernel
  7. Version: 3.13.0-32-generic
  8. Operating System: Ubuntu 14.04.1 LTS
Art
  • 903
  • 9
  • 20

2 Answers2

1

I made like was descried in "The Docker Book" by James Turnbull:

VOLUME /var/lib/docker

so all "heavy" stuff now is stored on host!

Hope It will help somebody

Art
  • 903
  • 9
  • 20
0

See my step-by-step description for resizing /var/lib/docker using resize2fs in another thread: Docker increase disk space

TL;DR:

> df -h
/dev/sda3                17.6G      4.1G     12.6G  25% /var/lib/docker

Step 0. install cfdisk, e2fsprogs-extra (resize2fs)
> apk add cfdisk
> apk add e2fsprogs-extra

Step 1. resize partition /dev/sda3
> cfdisk

Step 2. resize file-system
> resize2fs /dev/sda3

Step 3. verify free space
> df -h
/dev/sda3                37.3G      4.1G     31.4G  12% /var/lib/docker
Alex
  • 789
  • 8
  • 8