ImageLayers.io - Docker Visualization and Badges

Gary Paige

May 5, 2015

Share +

ImageLayers.io is a new project which provides a browser-based visualization of user-specified Docker Images and their layers. This visualization provides key information on the composition of a Docker Image and any commonalities between them. ImageLayers.io allows Docker users to easily discover best practices for image construction, and aid in determining which images are most appropriate for their specific use cases.

What are Layers?

Docker uses a union filesystem for managing images. Each layer of an image is the result of some action taken during the build. This could be installing a package, copying files from a local or remote source, or setting an environment variable. Each action creates a new layer in the filesystem; layers reference their parents and are cached, so they may be used as a part of an entirely different image. ImageLayers will show you these relationships as a tree.

Creating Smarter Docker Images

The layered filesystem is similar to a tree, and Docker is smart enough to branch from any layer if it sees the same work being done. For this reason, it's possible to consolidate work in order to optimize your images. There are two basic strategies for optimizing your Docker images: chaining commands and using smart base images.

Chaining Commands to reduce the number of layers

Here's a sample Dockerfile that pulls down a base image and installs a package.

The resulting image has fewer layers and therefore takes up less space than the first example.

ImageLayers lets you see each layer and its instruction more readily, making it easier for you to identify resource-sucking parts of your Dockerfile. For example, the analysis of the wordpress:latest image shows several run commands which could be concatenated using the technique above.

Extracting shared work to a base image

Using images with shared layers within your application will reduce download times and the overall filesystem size. A layer is only downloaded once regardless of how many images require it. Therefore, choosing a good base image for your application can be a performance boon. Using ImageLayers to investigate images on the DockerHub before they are downloaded is a quick way to find which layers may be shared. Within ImageLayers, a shared layer spans the image columns so it is easy to identify which images a layer may have in common. The more layers in common, the fewer requests are required to download the images, leading to better performance for your application.

ImageLayers Badge

Don't be the last image on the Docker Hub to have an ImageLayers badge! Use the 'Get an Embed Badge' feature to create an html link or a markdown fragment which can be embedded into a document.

ImageLayers was created to provide visual insight into the way an individual image is created and how many images can share layers. This information can be used to understand how the Docker unified file system behaves or fine tune an application composed of many images. Create an analysis of some of your favorite images and share the url with your friends.