VOOZH about

URL: https://thenewstack.io/find-vulnerabilities-in-container-images-with-docker-scan/

⇱ Find Vulnerabilities in Container Images with Docker Scan - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2021-09-24 09:01:23
Find Vulnerabilities in Container Images with Docker Scan
tutorial,
Containers / Linux / Security

Find Vulnerabilities in Container Images with Docker Scan

How to scanning Docker container images with the docker scan command, from either Docker Desktop or the Docker Engine on Linux.
Sep 24th, 2021 9:01am by Jack Wallen
👁 Featued image for: Find Vulnerabilities in Container Images with Docker Scan
Feature Image par Domianick de Pixabay

As you continue to shift your development process to cloud native computing, you’ll find yourself working with more and more container images. Those images might be officially vetted by the company that produced them (such as those from Red Hat, Canonical, Rocky Linux, NGINX, and AlmaLinux), or they might come from third-party sources that might not hold the same level of trust those larger companies have. When that is the case, what do you do? Do you blindly trust the images you are about to use are sans vulnerability? Or do you use a measure of caution to ensure that the very foundation of your container deployment doesn’t include deal-breaking or dangerous vulnerabilities?

The answer is always to use a measure of caution. Always. Even if you’re using official images from reputable companies, you should take the same precautions, because you never know when something might slip through the cracks.

But how do you scan those images for vulnerabilities? There are a lot of tools available for this task, some of them are costly services, while others are free alternatives that are pretty simple and safe to use.

One such tool is Docker Desktop. Now, recently it was revealed the Docker Desktop was no longer going to be free to use for large companies. But if you’re an individual developer or small business (with fewer than 250 employees), you can continue using the tool for free. For businesses with over 250 employees or higher than $10 million in annual revenue, you’ll have to have a paid subscription to continue using Docker Desktop.

But I’m focusing on individual cloud native developers who still need to ensure the containers they deploy are based on images free from vulnerabilities. To make that possible, Docker Desktop includes a handy scanning tool. Here’s the catch, unlike much of what you can do with Docker Desktop, the scanner is a command-line only tool. Fortunately, however, the command is very easy to use.

This scanning tool isn’t just available in Docker Desktop. You can also add it to Docker on Linux. I’m going to show you how to do just that after I introduce you to how the command is run on the macOS version of Docker Desktop.

Before you attempt this, you’ll first need to download and install Docker Desktop on your macOS machine. Fortunately, the developers have made this as simple as downloading a binary file and installing it as you would any application on your Mac.

After you’ve installed Docker Desktop, start it up and give it the necessary permissions it asks for. When the Docker Engine is running, you’re ready to pull down an image and start scanning.

How to Scan an Image

For the purposes of illustration, I have an older image of NGINX on my Macbook Pro and want to scan it. I pulled down that image some time ago with the command:

docker pull nginx

I can scan that image with:

docker scan nginx

The scan will start and complete fairly quickly (depending on the size of the image, of course). In my case, Docker will report that the base image is out of date and inform me I should pull down a new one. It will also report that it found a whopping 176 vulnerabilities in the image (Figure 1 — because it’s out of date).

👁 Image

Figure 1: My old NGINX image contains far too many vulnerabilities to use.

What if we update that image? Do so by pulling down the latest version, again with the command:

docker pull nginx:latest

After pulling down the latest version and re-running the scan, Docker reported the same results, which I found odd. Because of this, I tried scanning the image using the image ID instead. To find the image ID, I issued the command:

docker images

You should see an ID associated with the nginx image. After running the command docker scan ID (Where ID is the ID of the NGINX image), the new results reported that I was using the most secure version of the image, but still had 110 vulnerabilities associated with 136 dependencies.

For a bit of good news, I pulled down the latest AlmaLinux container image and ran a scan. The end results found 0 vulnerabilities. Huzzah!

How to Use Docker Scan on Linux

To use this command on Linux, we first must remove the old version of Docker with the command:

sudo apt-get remove docker docker-engine docker.io containerd runc -y

Once you’ve removed the older version, install the necessary dependencies with the command:

sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y

Add the Docker GPG key with:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Add the necessary repository with the command:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Update apt with:

sudo apt-get update

Finally, install Docker Engine with:

sudo apt-get install docker-ce docker-ce-cli containerd.io -y

Start and enable the Docker Engine with the commands:

sudo systemctl start docker
sudo systemctl enable docker

Add your user to the docker group with:

sudo usermod -aG docker $USER

Log out and log back in so the changes will take effect. Before you run a scan, however, you must log in to Docker Hub using an access token. You can generate an access token from the Security section of your DockerHub account. Once you’ve created an access token, log in with the command:

docker login -u USERNAME

Where USERNAME is your DockerHub username.

At this point, you should be able to scan images in Linux in the same method as described above.

Conclusion

And that’s all there is to scanning Docker container images with the docker scan command, from either Docker Desktop or the Docker Engine on Linux. You should put this step into your container development workflow, so you can be sure you’re starting with a solid security foundation.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
NGINX and Red Hat are sponsors of The New Stack.
TNS owner Insight Partners is an investor in: Docker.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.