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

The Hidden Cost of Legacy Firmware

The Hidden Costs of Legacy Firmware (and Why Modernization Can’t Wait)

Legacy firmware influences more than performance. It slows an organization’s ability to adapt. It shapes productivity, impacts security posture, and affects compliance readiness. In markets where firmware project management or embedded software project management can determine commercial success, failure to adapt means carrying a constant competitive handicap. The Price of Standing Still In older development environments, everyday work takes longer than it should. Engineers waste time untangling mismatched build environments, resolving bugs that resurface, and decoding design choices buried in

Read More »
Futuristic tunnel with overlays of charts and symbols

10 Easy Steps to Add Static Analysis to Your Firmware Build

When it comes to embedded system applications, security is one of the most important requirements. In addition to embedded security topics such as Bluetooth encryption, SSH, and TLS, modern firmware developers use a static analysis tool that checks for vulnerabilities in your source code. There are many existing static analysis tools (Cppcheck, Clang Sanitizers, etc.) that can do the job, but today I’d like to focus on one of our favorites, Flawfinder. Flawfinder is an open-source tool developed by David

Read More »
A finger moves toward the word update on a artistic depiction of technology

A Long Way From Home

Over The Air updates (OTA) takes advantage of modern connectivity for devices. Even for devices that aren’t normally connected to communication networks, it’s often possible to connect them to a computer or mobile device that is connected to the network and update them. It’s also become a common part of modern embedded development and release strategy.

Read More »