Docker & Containers (50 Qs)•Part 3: Advanced Internals, Scale & Production Security (Senior / Lead)
Read-Only Root Filesystems (`--read-only`): Immutable Container Hardening.
senior LevelCode ExampleSecurity & AuthDocker & Containers
In Simple Words: A golden rule of high-security container operations is ensuring that the container root filesystem is mounted as read-only.
bash
docker run -d \
--read-only \
--tmpfs /tmp:rw,noexec,nosuid,size=64m \
--tmpfs /run:rw,noexec,nosuid,size=16m \
my-app:v1
- If an attacker compromises the container through an application vulnerability (e.g., Log4Shell, SQL injection, remote code execution):
- They cannot download malware binaries (
curl -o /bin/miner). - They cannot overwrite system configurations or libraries.
- Any required temporary file writes are restricted to memory-backed, non-executable tmpfs mounts (
/tmp).
- They cannot download malware binaries (