Roadmap › 3. Cloud & DevOps › Step 35
Dk
Docker & Containers
Containers vs VMs, images and layers, Dockerfile for .NET, multi-stage builds, volumes, networks, Docker Compose, registries, security, debugging and production best practices.
Quick revision for interview day. Print it or save it as a PDF.
CLI
bash
docker build -t app:1.0 . docker run -d -p 8080:8080 --name a app:1.0
docker ps -a docker logs -f a
docker exec -it a sh docker stop a && docker rm a
docker images docker rmi app:1.0
docker tag app:1.0 myacr.azurecr.io/app:1.0
docker push myacr.azurecr.io/app:1.0 docker pull ...
docker volume ls / create / rm docker network ls / create
docker inspect a docker stats
docker system prune -a docker history app:1.0Compose
bash
docker compose up -d --build | ps | logs -f svc | exec svc sh | down [-v]Dockerfile essentials
FROM · WORKDIR · COPY (prefer) / ADD · RUN · ENV / ARG · EXPOSE · USER · HEALTHCHECK · ENTRYPOINT (exec form) + CMD (default args) · multi-stage COPY --from=build.
.NET specifics
Images: sdk / aspnet / runtime / runtime-deps · .NET 8+: port 8080, non-root app user · dotnet publish -t:PublishContainer · chiseled images.
Lifecycle
Created → Running → Paused → Exited → Removed · stop = SIGTERM then SIGKILL (10 s) · restart policies: no / on-failure / always / unless-stopped.
Exit codes
0 ok · 1 app error · 137 SIGKILL/OOM · 139 segfault · 143 SIGTERM.
Best practices
Multi-stage · small pinned base · non-root · no secrets in layers · .dockerignore · cache-friendly order · scan images · logs to stdout · health checks · immutable tags.