Even if you don't share volumes, there are still potential security risks when running a remotely downloaded Docker image. For instance, the image may contain code that runs with elevated privileges inside the container, allowing it to perform actions such as accessing the host's network or consuming host resources.
Additionally, the image could contain exploits or vulnerabilities that can be used to compromise the host system. To minimize the risk, it's recommended to only run images from trusted sources, to inspect the image and its code before running, and to run the image in a container with the least amount of privileges. For example, using the --user
option to run the container as a non-root user.
You can use Snyk to scan your Docker images for known vulnerabilities. To start using Snyk, you'll need to create a free account on their website. Snyk provides a command-line interface (CLI) that you can use to scan your Docker images. You can install the Snyk CLI by following the instructions in the Snyk documentation. To scan a Docker image, use the Snyk monitor command and specify the image name and registry.
Example:
snyk monitor docker://image_name
After the scan is complete, Snyk will display a report of the vulnerabilities found in the image, including the severity, CVSS score, and details on how to remediate the issue. If vulnerabilities are found, Snyk provides guidance on how to remediate them. This may include updating the image to a more recent version, installing security patches, or reconfiguring the image to reduce its attack surface.