Run containers in production avoiding common crashes, security holes, and resource traps.
apt-get update and apt-get install in separate RUN layers = stale packages weeks later — always combine thempython:latest today is different than python:latest tomorrow — pin versions like python:3.11.5-slim--from=builder copies from wrong stage silently-m 512m on every containerUSER nonroot or security scans fail and platforms rejectlocalhost inside container is container's localhost, not host — bind to 0.0.0.00.0.0.0 by default — use 127.0.0.1:5432:5432 for local-onlydepends_on waits for container start, not service ready — use condition: service_healthy with healthcheck.env file in wrong directory silently ignored — must be next to docker-compose.yml:z suffixdocker system prune doesn't remove named volumes — add -volumes flag explicitlydocker rm deletes datadocker image prune regularlydocker builder prune reclaims spacedocker container prune or --rm on rundocker network prune--privileged disables all security — almost never needed, find specific capability insteaddocker inspect --format='{{.State.ExitCode}}'docker logs <container>docker cp files out or use debug sidecardocker cp deadcontainer:/path ./local