instruction: How do you implement comprehensive container security scanning?
output: Security | Docker Docs Get started Guides Manuals Reference Ask&nbsp;AI { switch(e.key) { case 'k': if (e.metaKey || e.ctrlKey) { e.preventDefault(); $el.focus(); } break; } }" tabindex=0> Start typing to search or try Ask AI . Contact support { localStorage.setItem('theme-preference', value); document.firstElementChild.className = value; })" @click="theme = (theme === 'dark' ? 'light' : 'dark')"> { const container = $el; // The div with overflow const item = document.getElementById('sidebar-current-page') if (item) { const containerTop = container.scrollTop; const containerBottom = containerTop + container.clientHeight; const itemTop = item.offsetTop - container.offsetTop; const itemBottom = itemTop + item.offsetHeight; // Scroll only if the item is out of view if (itemBottom > containerBottom - 200) { container.scrollTop = itemTop - (container.clientHeight / 2 - item.offsetHeight / 2); } } })" class="bg-background-toc dark:bg-background-toc fixed top-0 z-40 hidden h-screen w-full flex-none overflow-x-hidden overflow-y-auto md:sticky md:top-16 md:z-auto md:block md:h-[calc(100vh-64px)] md:w-[320px]" :class="{ 'hidden': ! $store.showSidebar }"> Back Ask&nbsp;AI { switch(e.key) { case 'k': if (e.metaKey || e.ctrlKey) { e.preventDefault(); $el.focus(); } break; } }" tabindex=0> Start typing to search or try Ask AI . Contact support { localStorage.setItem('theme-preference', value); document.firstElementChild.className = value; })" @click="theme = (theme === 'dark' ? 'light' : 'dark')"> Manuals Get started Guides Reference Open source Docker Engine Install Ubuntu Debian RHEL Fedora Raspberry Pi OS (32-bit) CentOS SLES (s390x) Binaries Post-installation steps Storage Volumes Bind mounts tmpfs mounts Storage drivers Select a storage driver BTRFS storage driver Device Mapper storage driver (deprecated) OverlayFS storage driver VFS storage driver windowsfilter storage driver ZFS storage driver containerd image store Networking Packet filtering and firewalls Network drivers Bridge network driver Host network driver IPvlan network driver Macvlan network driver None network driver Overlay network driver Tutorials Networking using a macvlan network Networking using the host network Networking with overlay networks Networking with standalone containers CA certificates Legacy container links Containers Start containers automatically Run multiple processes in a container Resource constraints Runtime metrics Running containers CLI Completion Proxy configuration Filter commands Format command and log output OpenTelemetry for the Docker CLI Daemon Start the daemon Use IPv6 networking Daemon proxy configuration Live restore Alternative container runtimes Collect Docker metrics with Prometheus Configure remote access for Docker daemon Read the daemon logs Troubleshooting the Docker daemon Manage resources Docker contexts Docker object labels Prune unused Docker objects Logs and metrics Configure logging drivers Customize log driver output Logging drivers Amazon CloudWatch Logs logging driver ETW logging driver Fluentd logging driver Google Cloud Logging driver Graylog Extended Format logging driver Journald logging driver JSON File logging driver Local file logging driver Splunk logging driver Syslog logging driver Use a logging driver plugin Use docker logs with remote logging drivers Security Rootless mode Antivirus software and Docker AppArmor security profiles for Docker Content trust in Docker Automation with content trust Delegations for content trust Deploy Notary Server with Compose Manage keys for content trust Play in a content trust sandbox Docker security non-events Isolate containers with a user namespace Protect the Docker daemon socket Seccomp security profiles for Docker Verify repository client with certificates Swarm mode Administer and maintain a swarm of Docker Engines Deploy a stack to a swarm Deploy services to a swarm Getting started with Swarm mode Create a swarm Add nodes to the swarm Deploy a service to the swarm Inspect a service on the swarm Scale the service in the swarm Delete the service running on the swarm Apply rolling updates to a service Drain a node on the swarm How swarm works How nodes work How services work Manage swarm security with public key infrastructure (PKI) Swarm task states Join nodes to a swarm Lock your swarm to protect its encryption key Manage nodes in a swarm Manage sensitive data with Docker secrets Manage swarm service networks Raft consensus in swarm mode Run Docker Engine in swarm mode Store configuration data using Docker Configs Swarm mode key concepts Use Swarm mode routing mesh Deprecated features Docker Engine plugins Access authorization plugin Docker log driver plugins Docker network driver plugins Docker Plugin API Docker volume plugins Plugin Config Version 1 of Plugin V2 Use Docker Engine plugins Release notes Engine v28 Engine v27 Engine v26.1 Engine v26.0 Engine v25.0 Engine v24.0 Engine v23.0 Engine v20.10 Engine v19.03 Engine v18.09 Engine v18.06 Engine v18.05 Engine v18.04 Engine v18.03 Engine v18.02 Engine v18.01 Engine v17.12 Engine v17.11 Engine v17.10 Engine v17.09 Engine v17.07 Engine v17.06 Engine v17.05 Engine v17.04 Engine v17.03 Prior releases Docker Build Core concepts Docker Build Overview Dockerfile overview Build context Building Multi-stage Variables Secrets Multi-platform Export binaries Container Device Interface (CDI) Best practices Base images Build checks New Builders Build drivers Docker container driver Docker driver Kubernetes driver Remote driver Manage builders Bake Introduction Targets Inheritance Variables Expressions Functions Matrix targets Contexts Bake file reference Bake standard library functions Building with Bake from a Compose file Overriding configurations Remote Bake file definition Cache Build cache invalidation Build garbage collection Cache storage backends Amazon S3 cache Azure Blob Storage cache GitHub Actions cache Inline cache Local cache Registry cache Optimize cache usage in builds CI GitHub Actions Annotations Attestations Build checks Build secrets Build summary BuildKit configuration Cache management Copy image between registries Export to Docker Local registry Multi-platform image Named contexts Push to multiple registries Reproducible builds Share image between jobs Tags and labels Test before push Update Docker Hub description Metadata Annotations Build attestations Image attestation storage Provenance attestations SBOM attestations SLSA definitions Exporters Image and registry exporters Local and tar exporters OCI and Docker exporters BuildKit buildkitd.toml Configure BuildKit Custom Dockerfile syntax Dockerfile release notes Debugging OpenTelemetry support Build release notes Docker Compose Introduction to Compose How Compose works Why use Compose? History and development Install Plugin Standalone Uninstall Quickstart How-tos Specify a project name Use lifecycle hooks Use service profiles Control startup order Use environment variables Set environment variables Environment variables precedence Pre-defined environment variables Interpolation Best practices Build dependent images Use Compose Watch Secrets in Compose Networking Use multiple Compose files Merge Extend Include Enable GPU support Use Compose in production OCI artifact applications New Use provider services New Compose Bridge Usage Customize Support and feedback FAQs Give feedback Sample apps Releases Release notes Migrate to Compose v2 MCP Gateway Testcontainers AI Ask Gordon Beta Model Context Protocol (MCP) Built-in tools in Gordon Configure MCP servers with YAML Model Runner Beta Get started with DMR DMR REST API DMR examples MCP Catalog and Toolkit Beta MCP Catalog MCP Toolkit Hub MCP server AI and Docker Compose Use AI models in Compose New Products Docker Desktop Setup Install Mac Mac permission requirements Windows Windows permission requirements Linux Ubuntu Debian Fedora Arch RHEL VM or VDI environments Sign in Allowlist Explore Docker Desktop Containers Images Volumes Builds Resource Saver mode Pause Docker Desktop Features and capabilities Networking GPU support USB/IP support Deploy on Kubernetes Synchronized file shares containerd image store Wasm workloads Beta Docker Desktop CLI Virtual Machine Manager WSL Best practices Custom kernels on WSL Use WSL Settings and maintenance Change settings Backup and restore data Troubleshoot and support Troubleshoot and diagnose Common topics Known issues Get support for Docker Desktop FAQs General Mac Windows Linux Releases Give feedback Uninstall Fix startup issue for Mac Release notes Docker Hardened Images New Quickstart About Hardened images Image types Image testing Responsibility overview Features Flexibility Continuous patching Enterprise support Hardened, secure images Seamless integration How-tos Explore images Mirror an image Customize an image Use an image Verify an image Manage images Scan an image Enforce image usage Migrate an app Debug a container Core concepts Attestations CIS Benchmark Code signing CVEs Distroless images FIPS glibc and musl Hardening Image digests Image provenance Immutability SBOMs SLSA Software Supply Chain Security SSDLC STIG VEX Troubleshoot Docker Offload Beta Quickstart About Configure Usage & billing Optimize usage Troubleshoot Give feedback Docker Build Cloud Setup Usage Continuous integration Optimization Builder settings Release notes Docker Hub Quickstart Library Search Trusted content Catalogs Mirror Repositories Create Manage Repository information Access Images Tags Immutable tags Image Management Software artifacts Push images Move images Image security insights Webhooks Automated builds Set up Link accounts Automated repository tests Advanced options Manage autobuilds Troubleshoot Trusted content Docker Official Images Docker Verified Publisher Program Docker-Sponsored Open Source Program Insights and analytics Archive Delete Personal settings Usage and limits Pulls Optimize usage Service accounts Troubleshoot Release notes Docker Scout Install Quickstart Explore Dashboard Docker Scout image analysis Docker Scout metrics exporter Image details view Manage vulnerability exceptions How-tos Create an exception using the GUI Create an exception using the VEX Docker Scout environment variables Docker Scout SBOMs Use Scout with different artifact types Deep dive Advisory database sources and matching service Data collection and storage in Docker Scout Policy Evaluation Configure policies Docker Scout health scores Evaluate policy compliance in CI Remediation with Docker Scout View Docker Scout policy status Integrations Code quality SonarQube Container registries Amazon ECR Azure Container Registry Continuous Integration Azure DevOps Pipelines Circle CI GitHub Actions GitLab CI/CD Jenkins Integrating Docker Scout with environments Generic (CLI) Sysdig Source code management GitHub Team collaboration Slack Release notes CLI release notes Platform release notes Docker for GitHub Copilot EA Install Usage Example prompts Docker Extensions Marketplace extensions Non-marketplace extensions Configure a private marketplace Settings and feedback Extensions SDK The build and publish process Quickstart Part one: Build Create a simple extension Create an advanced frontend extension Add a backend to your extension Part two: Publish Add labels Validate Package and release your extension Share your extension Publish in the Marketplace Build multi-arch extensions Architecture Metadata Security Design and UI styling Guidelines Docker design principles MUI best practices Developer Guides Authentication Interacting with Kubernetes Invoke host binaries Use the Docker socket Developer SDK tools Test and debug Continuous Integration (CI) CLI reference Extension APIs Dashboard Docker Extension Backend Extension UI API Navigation Testcontainers Cloud Deprecated products and features Release lifecycle Platform Billing Add or update a payment method Manage your billing information 3D Secure authentication View billing history Change your billing cycle Submit a tax exemption certificate FAQs Docker accounts Accounts Create an account Manage an account Deactivate an account Security Personal access tokens Two-factor authentication Recover your Docker account FAQs General Container Network and VM Single sign-on General Domains Enforcement Identity providers User management Security announcements Subscription Subscriptions and features Set up your subscription Scale your subscription Manage seats Change your subscription Docker Desktop license agreement FAQs Release notes Enterprise Administration Organization administration Create your organization Onboard your organization Manage organization members Convert an account into an organization Create and manage a team Deactivate an organization Manage Docker products Activity logs Organization information Insights Company administration overview Create a company Manage company members Manage company organizations Manage company owners FAQ Organization Company Deploy Docker Desktop MSI installer PKG installer MS Store Deploy with Intune Deploy with Jamf Pro Microsoft Dev Box FAQs Security Single sign-on Configure Connect Manage Provision Just-in-Time SCIM Group mapping Enforce sign-in Configure Roles and permissions Manage domains Hardened Docker Desktop Enhanced Container Isolation Enable ECI Configure advanced settings Limitations FAQs Settings Management Use a JSON file Use the Admin Console Desktop settings reporting Settings reference Registry Access Management Image Access Management Air-gapped containers Organization access tokens Troubleshoot Troubleshoot provisioning Troubleshoot SSO Home / Manuals / Docker Engine / Security Docker Engine security Page options Copy page as Markdown for LLMs View page as plain text Ask questions with Docs AI Claude Open in Claude Table of contents Kernel namespaces Control groups Docker daemon attack surface Linux kernel capabilities Docker Content Trust signature verification Other kernel security features Conclusions Related information There are four major areas to consider when reviewing Docker security: The intrinsic security of the kernel and its support for namespaces and cgroups The attack surface of the Docker daemon itself Loopholes in the container configuration profile, either by default, or when customized by users. The "hardening" security features of the kernel and how they interact with containers. Kernel namespaces Docker containers are very similar to LXC containers, and they have similar security features. When you start a container with docker run , behind the scenes Docker creates a set of namespaces and control groups for the container. Namespaces provide the first and most straightforward form of isolation. Processes running within a container cannot see, and even less affect, processes running in another container, or in the host system. Each container also gets its own network stack, meaning that a container doesn't get privileged access to the sockets or interfaces of another container. Of course, if the host system is setup accordingly, containers can interact with each other through their respective network interfaces — just like they can interact with external hosts. When you specify public ports for your containers or use links then IP traffic is allowed between containers. They can ping each other, send/receive UDP packets, and establish TCP connections, but that can be restricted if necessary. From a network architecture point of view, all containers on a given Docker host are sitting on bridge interfaces. This means that they are just like physical machines connected through a common Ethernet switch; no more, no less. How mature is the code providing kernel namespaces and private networking? Kernel namespaces were introduced between kernel version 2.6.15 and 2.6.26 . This means that since July 2008 (date of the 2.6.26 release ), namespace code has been exercised and scrutinized on a large number of production systems. And there is more: the design and inspiration for the namespaces code are even older. Namespaces are actually an effort to reimplement the features of OpenVZ in such a way that they could be merged within the mainstream kernel. And OpenVZ was initially released in 2005, so both the design and the implementation are pretty mature. Control groups Control Groups are another key component of Linux containers. They implement resource accounting and limiting. They provide many useful metrics, but they also help ensure that each container gets its fair share of memory, CPU, disk I/O; and, more importantly, that a single container cannot bring the system down by exhausting one of those resources. So while they do not play a role in preventing one container from accessing or affecting the data and processes of another container, they are essential to fend off some denial-of-service attacks. They are particularly important on multi-tenant platforms, like public and private PaaS, to guarantee a consistent uptime (and performance) even when some applications start to misbehave. Control Groups have been around for a while as well: the code was started in 2006, and initially merged in kernel 2.6.24. Docker daemon attack surface Running containers (and applications) with Docker implies running the Docker daemon. This daemon requires root privileges unless you opt-in to Rootless mode , and you should therefore be aware of some important details. First of all, only trusted users should be allowed to control your Docker daemon. This is a direct consequence of some powerful Docker features. Specifically, Docker allows you to share a directory between the Docker host and a guest container; and it allows you to do so without limiting the access rights of the container. This means that you can start a container where the /host directory is the / directory on your host; and the container can alter your host filesystem without any restriction. This is similar to how virtualization systems allow filesystem resource sharing. Nothing prevents you from sharing your root filesystem (or even your root block device) with a virtual machine. This has a strong security implication: for example, if you instrument Docker from a web server to provision containers through an API, you should be even more careful than usual with parameter checking, to make sure that a malicious user cannot pass crafted parameters causing Docker to create arbitrary containers. For this reason, the REST API endpoint (used by the Docker CLI to communicate with the Docker daemon) changed in Docker 0.5.2, and now uses a Unix socket instead of a TCP socket bound on 127.0.0.1 (the latter being prone to cross-site request forgery attacks if you happen to run Docker directly on your local machine, outside of a VM). You can then use traditional Unix permission checks to limit access to the control socket. You can also expose the REST API over HTTP if you explicitly decide to do so. However, if you do that, be aware of the above mentioned security implications. Note that even if you have a firewall to limit accesses to the REST API endpoint from other hosts in the network, the endpoint can be still accessible from containers, and it can easily result in the privilege escalation. Therefore it is mandatory to secure API endpoints with HTTPS and certificates . Exposing the daemon API over HTTP without TLS is not permitted, and such a configuration causes the daemon to fail early on startup, see Unauthenticated TCP connections . It is also recommended to ensure that it is reachable only from a trusted network or VPN. You can also use DOCKER_HOST=ssh://USER@HOST or ssh -L /path/to/docker.sock:/var/run/docker.sock instead if you prefer SSH over TLS. The daemon is also potentially vulnerable to other inputs, such as image loading from either disk with docker load , or from the network with docker pull . As of Docker 1.3.2, images are now extracted in a chrooted subprocess on Linux/Unix platforms, being the first-step in a wider effort toward privilege separation. As of Docker 1.10.0, all images are stored and accessed by the cryptographic checksums of their contents, limiting the possibility of an attacker causing a collision with an existing image. Finally, if you run Docker on a server, it is recommended to run exclusively Docker on the server, and move all other services within containers controlled by Docker. Of course, it is fine to keep your favorite admin tools (probably at least an SSH server), as well as existing monitoring/supervision processes, such as NRPE and collectd. Linux kernel capabilities By default, Docker starts containers with a restricted set of capabilities. What does that mean? Capabilities turn the binary "root/non-root" dichotomy into a fine-grained access control system. Processes (like web servers) that just need to bind on a port below 1024 do not need to run as root: they can just be granted the net_bind_service capability instead. And there are many other capabilities, for almost all the specific areas where root privileges are usually needed. This means a lot for container security. Typical servers run several processes as root , including the SSH daemon, cron daemon, logging daemons, kernel modules, network configuration tools, and more. A container is different, because almost all of those tasks are handled by the infrastructure around the container: SSH access are typically managed by a single server running on the Docker host cron , when necessary, should run as a user process, dedicated and tailored for the app that needs its scheduling service, rather than as a platform-wide facility Log management is also typically handed to Docker, or to third-party services like Loggly or Splunk Hardware management is irrelevant, meaning that you never need to run udevd or equivalent daemons within containers Network management happens outside of the containers, enforcing separation of concerns as much as possible, meaning that a container should never need to perform ifconfig , route , or ip commands (except when a container is specifically engineered to behave like a router or firewall, of course) This means that in most cases, containers do not need "real" root privileges at all* And therefore, containers can run with a reduced capability set; meaning that "root" within a container has much less privileges than the real "root". For instance, it is possible to: Deny all "mount" operations Deny access to raw sockets (to prevent packet spoofing) Deny access to some filesystem operations, like creating new device nodes, changing the owner of files, or altering attributes (including the immutable flag) Deny module loading This means that even if an intruder manages to escalate to root within a container, it is much harder to do serious damage, or to escalate to the host. This doesn't affect regular web apps, but reduces the vectors of attack by malicious users considerably. By default Docker drops all capabilities except those needed , an allowlist instead of a denylist approach. You can see a full list of available capabilities in Linux manpages . One primary risk with running Docker containers is that the default set of capabilities and mounts given to a container may provide incomplete isolation, either independently, or when used in combination with kernel vulnerabilities. Docker supports the addition and removal of capabilities, allowing use of a non-default profile. This may make Docker more secure through capability removal, or less secure through the addition of capabilities. The best practice for users would be to remove all capabilities except those explicitly required for their processes. Docker Content Trust signature verification Docker Engine can be configured to only run signed images. The Docker Content Trust signature verification feature is built directly into the dockerd binary. This is configured in the Dockerd configuration file. To enable this feature, trustpinning can be configured in daemon.json , whereby only repositories signed with a user-specified root key can be pulled and run. This feature provides more insight to administrators than previously available with the CLI for enforcing and performing image signature verification. For more information on configuring Docker Content Trust Signature Verification, go to Content trust in Docker . Other kernel security features Capabilities are just one of the many security features provided by modern Linux kernels. It is also possible to leverage existing, well-known systems like TOMOYO, AppArmor, SELinux, GRSEC, etc. with Docker. While Docker currently only enables capabilities, it doesn't interfere with the other systems. This means that there are many different ways to harden a Docker host. Here are a few examples. You can run a kernel with GRSEC and PAX. This adds many safety checks, both at compile-time and run-time; it also defeats many exploits, thanks to techniques like address randomization. It doesn't require Docker-specific configuration, since those security features apply system-wide, independent of containers. If your distribution comes with security model templates for Docker containers, you can use them out of the box. For instance, we ship a template that works with AppArmor and Red Hat comes with SELinux policies for Docker. These templates provide an extra safety net (even though it overlaps greatly with capabilities). You can define your own policies using your favorite access control mechanism. Just as you can use third-party tools to augment Docker containers, including special network topologies or shared filesystems, tools exist to harden Docker containers without the need to modify Docker itself. As of Docker 1.10 User Namespaces are supported directly by the docker daemon. This feature allows for the root user in a container to be mapped to a non uid-0 user outside the container, which can help to mitigate the risks of container breakout. This facility is available but not enabled by default. Refer to the daemon command in the command line reference for more information on this feature. Additional information on the implementation of User Namespaces in Docker can be found in this blog post . Conclusions Docker containers are, by default, quite secure; especially if you run your processes as non-privileged users inside the container. You can add an extra layer of safety by enabling AppArmor, SELinux, GRSEC, or another appropriate hardening system. If you think of ways to make docker more secure, we welcome feature requests, pull requests, or comments on the Docker community forums. Related information Use trusted images Seccomp security profiles for Docker AppArmor security profiles for Docker On the Security of Containers (2014) Docker swarm mode overlay network security model Edit this page Request changes Table of contents Kernel namespaces Control groups Docker daemon attack surface Linux kernel capabilities Docker Content Trust signature verification Other kernel security features Conclusions Related information Product offerings Pricing About us Contribute Read llms.txt Cookies Settings Terms of Service Status Legal Copyright © 2013-2025 Docker Inc. All rights reserved.