Guest User

Untitled

a guest
Jun 22nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. The "size" and "virtual size" describe the amount of disk space used by a container. Let me try and explain:
  2.  
  3. When starting a container, the image that the container is started from is mounted read-only. On top of that, a writable layer is mounted, in which any changes made to the container are written.
  4.  
  5. The read-only layers of an image can be shared between any container that is started from the same image, whereas the "writable" layer is unique per container (because: you don't want changes made in container "a" to appear in container "b" 😄)
  6.  
  7. Back to the docker ps -s output;
  8.  
  9. - The "size" information shows the amount of data (on disk) that is used for the writable layer of each container
  10. - The "virtual size" is the amount of disk-space used for the read-only image data used by the container.
  11.  
  12. The reason it's named "virtual size", is that (as described earlier), the disk space for the read-only layer(s) can be shared between containers, so only take up disk space once (perhaps a different name ("shared" size?) would have been better in hindsight, but naming is hard 😄).
  13.  
  14. In the example below, I started 10 nginx containers;
  15.  
  16. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE
  17. 6ca0cef8db8d nginx "nginx -g 'daemon ..." 55 seconds ago Up 54 seconds 80/tcp, 443/tcp pedantic_mahavira 2B (virtual 183MB)
  18. 0b75532c34d2 nginx "nginx -g 'daemon ..." 56 seconds ago Up 55 seconds 80/tcp, 443/tcp hardcore_haibt 2B (virtual 183MB)
  19. a86d8818795d nginx "nginx -g 'daemon ..." 56 seconds ago Up 55 seconds 80/tcp, 443/tcp happy_pasteur 2B (virtual 183MB)
  20. 3e9151f0332d nginx "nginx -g 'daemon ..." 57 seconds ago Up 56 seconds 80/tcp, 443/tcp pensive_khorana 2B (virtual 183MB)
  21. 429c418114a1 nginx "nginx -g 'daemon ..." 57 seconds ago Up 56 seconds 80/tcp, 443/tcp nostalgic_bose 2B (virtual 183MB)
  22. 01f6a0818b32 nginx "nginx -g 'daemon ..." 58 seconds ago Up 57 seconds 80/tcp, 443/tcp zen_davinci 2B (virtual 183MB)
  23. 9ed93ee43912 nginx "nginx -g 'daemon ..." 58 seconds ago Up 58 seconds 80/tcp, 443/tcp unruffled_ptolemy 2B (virtual 183MB)
  24. c7c17bf50744 nginx "nginx -g 'daemon ..." 59 seconds ago Up 58 seconds 80/tcp, 443/tcp zen_khorana 2B (virtual 183MB)
  25. a7b0502d95ce nginx "nginx -g 'daemon ..." About a minute ago Up About a minute 80/tcp, 443/tcp gallant_leavitt 2B (virtual 183MB)
  26. 8b9e9ee6c4e8 nginx "nginx -g 'daemon ..." About a minute ago Up About a minute 80/tcp, 443/tcp clever_pasteur 2B (virtual 183MB)
  27. All these containers use the same image, so the "Virtual size" (183MB in the example) is used only once, irregardless of how many containers are started from the same image - I can start 1 container or a thousand; no extra disk space is used. The "Size" (2B in the example) is unique per container though, so the total space used on disk is:
  28.  
  29. 183MB + 10 * 2B
  30.  
  31. Be aware that the size shown does not include all disk space used for a container. Things that are not included currently are;
  32.  
  33. disk space used for log-files (if you use the json-file logging driver) - which can be quite a bit if your container generates a lot of logs, and log-rotation (max-file / max-size logging options) is not configured
  34. volumes used by the container
  35. disk space used for the container's configuration files (hostconfig.json, config.v2.json, hosts, hostname, resolv.conf) - although these files are small
  36. memory written to disk (if swapping is enabled)
  37. checkpoints (if you're using the experimental checkpoint/restore feature)
Add Comment
Please, Sign In to add comment