In addition to cost, often customers run into performance and timeout-related issues when the image size is large. Depending on the environment you are using to deploy the Docker containers, many times you have constraints on disk size, so it’s important to reduce the image size. To reduce the maximum size of the disk image file: Select the Docker icon and then select Preferences Resources Advanced. The Disk image size section contains a slider that allows you to change the maximum size of the disk image. Adjust the slider to set a lower limit.
whaler
What? A command-line tool for visually investigating the disk usage of docker images The next black ops.
Why? Large images are slow to move and expensive to store. They cost developer productivity by lengthening devops tasks and often contain unnecessary data
Who is this for? Timer online. Primarily for engineers working with images containing Python packages.
User Stories
This tool should allow you to answer questions such as:
- Which file types are occupying the most disk space?
- Which are my largest Python packages?
- What are my unknown causes of high disk usage?
Quick start
Run against a local directory
Run against a docker image
The tool will pull the image first if it is not present.
Play with a hosted demo
Limitations
- Platform: whaler uses
du
to gather disk usage data. It must be present in your docker image - Scale: I have tested the web UI with up to 500,000 file system nodes with
du
output of up to ~100MB.
Alternatives/Complements to this tool:
- Whaler can tell you what is taking up space in the final layer of your Docker image, but you may have intermediate layers which are contributing to the image size. For diving through the layers, use dive
- Related: read up on multi-stage builds to understand how to mitigate the problem of intermediate layers bloating your image.
- For investigating disk usage in non-docker directories, Disk Inventory X is a great tool on OS X which I have based whaler on.
- GoogleContainerTools/distroless for base images not containing standard linux distro contents
Docker Get Image Size
See also
Developing
See
.github/workflows/test.yml
for the development platform and setup.![Docker image size limit Docker image size limit](https://avatars.discourse.org/v2/letter/b/e95f7d/200.png)
For UI, see whaler-ui
GitHub
Here's a simple command to show you much disk space is being taken up by Docker images, containers, volumes and build cache.
Ubuntu Docker Image Size
Docker has a
system
sub-command that has a few useful commands. One of them is docker system df
which reports back disk space usage stats of your Docker installation.Docker Image Too Large
Here’s what the output of
docker system df
looks like on my machine:Node Docker Image Size
TYPE | TOTAL | ACTIVE | SIZE | RECLAIMABLE |
Images | 212 | 0 | 63.72GB | 63.72GB (100%) |
Containers | 0 | 0 | 0B | 0B |
Local Volumes | 77 | 0 | 1.01GB | 1.01GB (100%) |
Build Cache | 0 | 0 | 0B | 0B |
This is on a machine with dozens of real world Dockerized projects that are mostly Flask, Rails, Phoenix and NodeJS apps spanning across multiple versions.
My build cache is empty because I run
docker system prune
as a daily scheduled task. If you want to see how to set that up on any OS, check out Docker Tip #32.You can pry even deeper by using the
-v
flag (verbose). It will show you the unique image size for each image. You’d be surprised at how small some of them are!What does your df output look like? Let me know in the comments below.