The new, improved Snyk Container CLI
October 29, 2020
0 mins readAs more and more of you adopt containers for packaging up your applications, identifying vulnerabilities in them before you ship them is becoming incredibly important.
Snyk has had the ability to test your Docker images using our CLI for over a year now. With the latest release of the CLI, we’re improving the user experience for container users, as well as adding a few more useful features for advanced users.
A new container subcommand
Currently, you test container images using the --docker flag on either snyk test or snyk monitor. This works great for lots of users, and we won’t be breaking that behavior. But it has some downsides too, in particular when viewing the inline help.
If you’re just interested in testing your container images you need to wade through lots of options to determine which ones apply. So we’re introducing a new subcommand to snyk. You can now test your container images for vulnerabilities using:
If you want to send that information to Snyk, where we can display it and alert you in the future if new vulnerabilities are found, then the monitor command is also available.
Snyk makes it easy to test your images wherever they are. If the image is only in your local Docker daemon we’ll test that. If it’s available in a remote registry we’ll pull the image down and test that. Don’t have Docker installed on the machine where you’re testing? No problem. There are lots of different workflows around containers, Snyk makes it easy to test your images however you work.
To reiterate. The previous --docker flag will remain and simply act as an alias for the new command, including the new functionality. We take backward compatibility seriously and don’t want to break any automation you might have around our CLI tooling.
Container specific help
With the new container subcommand, we have Container specific help information available directly in the CLI. This makes it much easier to see straight away how you can use the CLI, from specifying a Dockerfile used to build the image, to excluding the vulnerabilities found in the base image or only reporting on high severity vulnerabilities.
Some new capabilities
The new snyk container subcommand also comes with some new features for power users.
If you’re working directly with container archives, rather than images, you can now test those for vulnerabilities with Snyk.
For instance, you can save an archive from Docker, and test the resulting archive file like so:
If you’re working directly with the standard OCI (Open Container Initiative) images you can test those too.
Last but not least, Snyk now supports testing Distroless images. Distroless is an interesting project from Google, producing container base images based on Debian packages, but without a shell, or package manager installed in order to improve security. So you can now test the Distroless base images or images you’ve built using them with Snyk as normal.
Next steps
We’re always working to improve the user experience of Snyk, whether in our CLI tool, the Snyk service, our API, or our various developer tools integrations. The new snyk container command should make it easier to use Snyk when you’re focused on containers, and we’ll have more interesting and useful functionality coming to this interface soon.
Get started in capture the flag
Learn how to solve capture the flag challenges by watching our virtual 101 workshop on demand.
