Trusting the Docker Images Your Code is Built On

We’ve written before about the benefits of using Docker in your development environments. You don’t have to write every image yourself, though! There are many existing images on Docker Hub and elsewhere that can get you quickly up and running. But unless you enjoy terrifying your IT department, please don’t run off and use any and every image you find! Like any piece of software, there are security vulnerabilities and potential bad actors. But there are also ways to mitigate the risks of using Docker. We won’t cover things you should be considering with any Linux install or third party software in this article. But these are the most important questions you need to ask before using a new Docker image and how to find the answers.

Who made this?

When using a new Docker image, ask yourself: Was this written by a company or open source community with a reputation to maintain? What are the authors’ goals? Do they have enough resources to keep their images up to date and respond to issues filed? A good indicator that authors are trustworthy on Docker Hub is whether the image has been flagged as an Official Image or is from a Verified Publisher. Even if you’re using images with these tags or similar ones from other registries, it’s still up to you to decide whether you trust the source of this image. But without them, it’s worth taking extra time to verify the identity, motivation, and capabilities of the authors.

Finally, do they provide the source code? In this case, that would be Dockerfiles and Docker Compose files as well as any programs or scripts they’ve added. Depending on your comfort with the company or person involved, you may not find this necessary, but it certainly is a good sign to see they are happy to freely share what they’ve built.

Book a Call with Dojo Five Embedded Experts

What’s in it?

If you have access to the source code, you can build the image yourself and know what’s in it and how it works. But what if you don’t have access to that? There are some commands you can run locally to take a look.

  • docker inspect will give you some of the information about the container, including any labels that the author has decided to add with what they think is relevant information.
  • docker manifest will give you the generated hash values for the images this image was built from
  • docker history will show the commands recently run on this image or container
  • docker top will show the currently running processes in your container

It’s also best to start with the smallest base images possible. If, for example, you don’t need to use Python, skip using containers that have Python installed at all. If the code isn’t there, the vulnerabilities aren’t either.

Image authors can also push new versions of images to the same tag. If you’re using tags, use the most descriptive tag available to reduce the chance you’ll have changes in your build environment. To use Python as an example again, prefer tags that have the version and the OS listed, python:3.8-alpine3.12, over the simple tag alone, python. To know with absolute certainty what image you’re using, use a SHA instead of a tag. A SHA is a generated hash value that is unique to every image, even if an author pushes a new image to the same tag. Many authors use a :latest tag, for instance. The image you pull will change every time the author pushes a new version to that tag. Using a SHA also protects you from unknowingly pulling images with malicious code if the author pushes new images to published tags for less honest reasons.

Okay, but what’s really in it?

There’s close to a full operating system in many images. That’s a lot of code and information to parse. Probably far more than you’re going to want to look at or want to know about. There are tools to test for best practices, common vulnerabilities, and malicious content or processes. You’ll see a Docker Certified flag on images on Docker Hub to note that the authors have done all of these tests before publishing. On other registries, look for similar proof that the authors are routinely ensuring their images are as stable and secure as possible.

However, with the reality of zero day bugs and the natural aging of code, it still makes sense for you to run tools like clair or use paid vulnerability analysis services. These tools can be set up in your Continuous Integration (CI) pipeline to scan images for the latest known vulnerabilities every time you use them.

Is this what I think it is?

To ensure that the container you’re pulling down is the same as what the registry says it is, you can enable Docker Content Trust. This restricts you to using only images with signed tags or the full SHA id as described above. Trusts are applied to individual tags, not to the entire image repository. So you may find that awesomeImage:v1 is signed, but awesomeImage:latest is not.

What is it running on?

Like a virtual machine, the hardware you run your containers on needs to keep itself safe. See the following aspects to consider:

This is where your IT department is your friend. They likely already have processes and procedures written to handle all of these concerns from running virtual machines.

Conclusion

Like any good tool, Docker comes with risks alongside the rewards. But you can avoid collateral damage by asking what the risks are and putting safeguards in place before you begin. If you have any questions, or see anything we missed here, we’d love to chat!

Next Steps

And if you have questions about an embedded project you’re working on, Dojo Five can help you with all aspects of your devops for embedded journey! 

Project leaders – you can book a call with us to start the conversation about your project that needs modern embedded expertise. Engineers – if you are looking for a better CI build platform, check out our EmbedOps product to increase your productivity.

Discover why Dojo Five EmbedOps is the embedded enterprise choice for build tool and test management.

Sign up to receive a free account to the EmbedOps platform and start building with confidence..

  • Connect a repo
  • Use Dev Containers with your Continuous Integration (CI) provider
  • Analyze memory usage
  • Integrate and visualize static analysis results
  • Perform Hardware-in-the-Loop (HIL) tests
  • Install the Command Line Interface for a developer-friendly experience

Subscribe to our Monthly Newsletter

Subscribe to our monthly newsletter for development insights delivered straight to your inbox.

Interested in learning more?

Best-in-class embedded firmware content, resources and best practices

Laptop with some code on screen

I want to write my first embedded program. Where do I start?

The boom in the Internet of Things (IoT) commercial devices and hobbyist platforms like the Raspberry Pi and Arduino have created a lot of options, offering inexpensive platforms with easy to use development tools for creating embedded projects. You have a lot of options to choose from. An embedded development platform is typically a microcontroller chip mounted on a circuit board designed to show off its features. There are typically two types out there: there are inexpensive versions, sometimes called

Read More »
Medical device monitoring vitals

IEC-62304 Medical Device Software – Software Life Cycle Processes Primer – Part 1

IEC-62304 Software Lifecycle requires a lot of self-reflection to scrutinize and document your development processes. There is an endless pursuit of perfection when it comes to heavily regulated industries. How can you guarantee something will have zero defects? That’s a pretty hefty task. The regulatory approach for the medical device industry is process control. The concept essentially states that if you document how every step must be completed, and provide checks to show every step has been completed properly, you

Read More »
Operating room filled with medical devices

IEC-62304 Medical Device Software – Software Life Cycle Processes Primer – Part II

Part I provides some background to IEC-62304. Part II provides a slightly more in-depth look at some of the specifics. The IEC 62304 Medical Device Software – Software Lifecycle Processes looks into your development processes for creating and maintaining your software. The standard is available for purchase here. So what activities does the standard look at? Here are some of the major topics. For any given topic, there will be a lot more specifics. This will look at a few

Read More »