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. 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.

There is a direct correlation between your Dockerfile and the number of layers in your image. Docker offers some advice on Dockerfile best practices, and we have also published an article on how to best optimize Docker images.

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.

FROM debian:wheezy

RUN wget -nv
RUN tar -xvf someutility-v1.0.0.tar.gz
RUN mv /tmp/someutility-v1.0.0/someutil /usr/bin/someutil
RUN rm -rf /tmp/someutility-v1.0.0
RUN rm /tmp/someutility-v1.0.0.tar.gz

Because there is a 1-to-1 correlation between the Dockerfile and the layers in the image, this image would have many layers. A new layer is created for each of the RUN commands.

Since each of the RUN commands above is related to the same package, we can chain them together and execute all of the commands on the same layers. That looks like this:

FROM debian:wheezy

RUN wget -nv && tar -xvf someutility-v1.0.0.tar.gz
  && mv /tmp/someutility-v1.0.0/someutil /usr/bin/someutil
  && rm -rf /tmp/someutility-v1.0.0
  && rm /tmp/someutility-v1.0.0.tar.gz

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.