Main idea
A container is not automatically secure just because it is isolated.
This page introduces practical Docker safety habits that reduce risk without making the setup overly complex for beginners.
A container is not automatically secure just because it is isolated.
Use trusted base images, avoid unnecessary packages, handle secrets carefully, and avoid running everything as root when possible.
Secrets baked directly into images are hard to control and risky to share.
# risky
ENV API_KEY=secret123
# better
# pass values at runtime insteadSecurity often improves when configuration and secrets stay outside the built image.
Next page: Lesson 17 explains how Docker usage changes between development and production environments.