Blog

The eight practices for Containerized Delivery on the Microsoft stack – PRACTICE 7: Explicit dependency management

06 Apr, 2018
Xebia Background Header Wave

This post is originally published as article within SDN Magazine on October 13th, 2017.
During the past year I supported several clients in their journey toward Containerized Delivery on the Microsoft stack. In this blogseries I’d like to share eight practices I learned while practicing Containerized Delivery on the Microsoft stack using Docker, both in a Greenfield and in a Brownfield situation. In the seventh blogpost of this series I want to talk about Explicit Dependency Management.

PRACTICE 7: Explicit Dependency Management

A lot of Docker and Compose files I have seen contain a reference to images, without specifying the version of the image, or with the default “latest” tag. Not explicitly specifying the version of an image can result in unexpected behavior and this is very risky.

 Docker file without version tag
Docker file without version tag

The reason for this is that every Docker host has its own local Docker image cache. Once an image-tag combination is found in your local cache, Docker will consume the cached blob on docker run instead of downloading the blob from the container registry. Making use of the “latest” tag could result in the fact that you get an older version of an image than the image you actually want. As shown in the figure below a docker run cornellk/test command on Host01 will run version 10.0.01 instead of the download of image version 10.0.02 from the registry.

The latest tag issue
The latest tag issue

You can test this scenario yourself by comparing the result of a docker run and docker pull command on an outdated image in the local cache. As you see in the image below, docker pull downloads newer image layers from the registry where docker run just starts a new container based on the outdated cached image.

Docker run vs docker pull in case of implicit versioning
Docker run vs docker pull in case of implicit versioning

Using the “latest” tag makes your build-and-release process non-repeatable. To avoid this, all you need to do is explicitly reference which version of an image you want.

More from this Series

Cornell Knulst
Cornell works for Xpirit, Hilversum, The Netherlands, as a trainer/architect. He is specialized in the domain of Application Lifecycle Management and Continuous Delivery, with a special focus on Microsoft-based technologies.
Questions?

Get in touch with us to learn more about the subject and related solutions

Explore related posts