codegurukool.com · Free coding tutorials & online compiler

Home › Docker Tutorial › Docker security basics

Docker security basics

Safer containers.

Good habits: use small official base images, pin versions, do not run as root (USER in the Dockerfile), never store secrets in images, scan images for known problems (docker scout), drop extra permissions (--cap-drop ALL) and make the file system read-only (--read-only) when the app allows it.

Example code

docker run --rm --read-only alpine touch /x

Run this code in the online editor

← Resource limitsTroubleshooting →