TERN - Inspect thy docker image
Tags: docker, devops, softwareinspection
Published: 2020-04-03 03:06:35

Docker is a commonly heard buzzword these days. Almost every major project on GitHub is now using docker. [opensource.com](https://opensource.com/resources/what-docker) summarizes docker as -

> *Docker is a tool designed to make it easier to
create, deploy, and run applications by using containers.*


What are containers then?

According to [wikipedia](https://en.wikipedia.org/wiki/LXC)
> *Containers offer operating-system-level virtualization through a virtual environment that has its own process and network space, instead of creating a full-fledged virtual machine.*

***

All container images have some sort of dependency chain associated with them. Suppose you are creating a container based on the mongo-DB base image. You might be familiar with the packages that you installed on top of the mongo-DB base image, but likely won’t know anything about the dependencies that the mongo-DB base image brings with it. Creating a software bill of materials (SBoM)  can help you make better decisions about your container-based infrastructure, integration, and deployment strategies.
Or, maybe you are just curious about the contents of the image you are using such as what packages are installed in it and which licenses govern those packages.


***

### Well then ***tern*** comes to the rescue.

***

Tern is an open-source container inspection tool for containers. Tern is currently available as a pip [package](https://pypi.org/project/tern/) but can also be cloned from its [GitHub repository](https://github.com/vmware/tern). The installation is straight-forward but it does require Docker to be installed on the host machine.
* Linux users can find installation instructions [here](https://github.com/vmware/tern#getting-started-on-linux)
* Windows and mac users can find installation instructions [here](https://github.com/vmware/tern#getting-started-with-vagrant)  


***

Once you've set up tern you can start inspecting docker images and dockerfiles.

*  To inspect locally pulled docker images or images available on DockerHub. 
 ``` tern report -i debian:jessie ```

*  To inspect local Dockerfiles.
``` tern report -d path/to/Dockerfile ```

Tern creates SBoM reports suitable to read over or to provide another tool for consumption. Currently, supported report formats are :
- summary (default)
- json
- yaml
- SPDX tag-value

You can read more about them [here.](https://github.com/vmware/tern#report-formats)


You can read more about them [here.](https://github.com/vmware/tern#report-formats)

***

Another thing that makes Tern special, is the beginner-friendly documentation, code readability, and community support. The maintainers are super active and respond to the issues raised very frequently. Also, you can raise your issue on the slack channel or get help if you feel stuck anywhere. The team is super friendly and responsive. I am a contributor at Tern now and I can say all this from personal experience.

*This is my very first article hope you guys like it. I didn't want to make it too long if you guys want a more detailed article comment below. I would like to thank [rose](github.com/rnjudge/) from Tern team for helping me out with this article*

Do checkout tern's [github repo.](http://github.com/vmware/tern)