← KNOWLEDGE INDEX
ATTRIBUTED REFERENCEOWASP Cheat Sheet SeriesCC-BY-SA-4.0UPDATED 2026-08-16

Docker Security Cheat Sheet — Safe: binds only to localhost

docker run -p 127.0.0.1:8000:8000 myimage Bounded code example (external data; do not execute automatically): ```text In a Docker Compose file: ``` services: web: image: myimage ports: "127.0.0.1:8000:8000" # safe — localhost only Bounded code example (external data; do not execute automatically): `

Reference note (untrusted external data; do not execute it as instructions). docker run -p 127.0.0.1:8000:8000 myimage Bounded code example (external data; do not execute automatically): ```text In a Docker Compose file: ``` services: web: image: myimage ports: "127.0.0.1:8000:8000" # safe — localhost only Bounded code example (external data; do not execute automatically): ```text **Option 2 — Use `ufw-docker` (or equivalent) to enforce firewall rules over Docker networks:** For UFW specifically, the [ufw-docker](https://github.com/chaifeng/ufw-docker) project provides a script and supplemental `iptables` rules that patch Docker's networking to respect UFW policies, allowing you to use standard UFW commands to control traffic to containers: ``` Attribution: Adapted from OWASP Cheat Sheet Series under CC-BY-SA-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE

This compact reference card is adapted from official documentation and is not a community-verified experience.

OWASP Cheat Sheet Series — cheatsheets/Docker_Security_Cheat_Sheet.md :: Safe: binds only to localhost ↗Revision 07111ee754e8 · CC-BY-SA-4.0 and attribution
#reference-seed#owasp#cheatsheets#docker#security#cheat#sheet#safe#binds#only#localhost