---
title: "Discussion on \"Docker for Backend Engineers Who Aren't DevOps\" | Hashnode"
description: "Discussion on \"Docker for Backend Engineers Who Aren't DevOps\". How Docker layers, build cache, and multi-stage builds actually work — and a production-ready Dockerfile for FastAPI on Cloud Run"
url: "https://hashnode.com/posts/docker-for-backend-engineers-who-aren-t-devops/6aeec08b6b600201bea513fb"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Docker for Backend Engineers Who Aren't DevOps](https://blog.madhav.dev/docker-for-backend-engineers-who-aren-t-devops?utm_source=hashnode&utm_medium=feed)

How Docker layers, build cache, and multi-stage builds actually work — and a production-ready Dockerfile for FastAPI on Cloud Run

Nov 7 · 6 min read · blog.madhav.dev  
Read the article

-   [#docker](https://hashnode.com/tag/docker)
-   [#cloud-run](https://hashnode.com/tag/cloud-run)
-   [#fastapi](https://hashnode.com/tag/fastapi)
-   [#backend-engineering](https://hashnode.com/tag/backend-engineering)
-   [#containers](https://hashnode.com/tag/containers)
-   [#python](https://hashnode.com/tag/python)
-   [#devops](https://hashnode.com/tag/devops)

## Written by

[Madhav Bhasin](https://hashnode.com/@madhavbhasin)

@madhavbhasin · Noida, India

  
[View profile](https://hashnode.com/@madhavbhasin)

Production patterns for backend engineers who are tired of hello-world tutorials.

Senior full-stack engineer and engineering lead with 5+ years building cloud-native systems at scale. I write about the things the docs don't cover — GCP, FastAPI, Terraform, event-driven architecture, and AI-powered backends. No hello-world demos.

## Responses 4

Markdown supported · ⌘↵ to post

[Rishabh Mishra](https://hashnode.com/@rushdeploy)

[Nov 8](https://hashnode.com/posts/docker-for-backend-engineers-who-aren-t-devops/6aeec08b6b600201bea513fb/comment/6aefe4fdf8418419009a8db8)

Layer order is the part I keep coming back to too. I would also pin the base image tag, so a rebuild months later does not silently pull a newer Python patch and change the cache behavior you describe.

[lepp-sd](https://hashnode.com/@snapcopier)

[Nov 7](https://hashnode.com/posts/docker-for-backend-engineers-who-aren-t-devops/6aeec08b6b600201bea513fb/comment/6aef9ef90ec4c8e0c8311314)

Solid writeup. Loved the part on build cache invalidation. I really enjoy your straightforward style and would definitely read a follow-up if you ever cover orchestration, especially managing stateful vs stateless services in Docker Swarm.

[Shubham Chaudhary](https://hashnode.com/@shubhamworks)

[Nov 7](https://hashnode.com/posts/docker-for-backend-engineers-who-aren-t-devops/6aeec08b6b600201bea513fb/comment/6aeef1d957bac4fb8e4a9491)

When I was learning Docker, my first-ever Docker image was ridiculously huge, and that was just for a simple Vite app created using "npm create vite@latest" and "npm install". Back then, I had no idea that .dockerignore even existed. Once I learned about it, I realised how much unnecessary stuff I was including in the build context.

[Steven Mock](https://hashnode.com/@stevenmock)

[Nov 7](https://hashnode.com/posts/docker-for-backend-engineers-who-aren-t-devops/6aeec08b6b600201bea513fb/comment/6aeecd466685843207051847)

The layer-ordering point is the one that saves real time. Put the dependency install before the code copy and most rebuilds stop reinstalling everything after a one-line change. The .dockerignore point belongs right next to it — I've seen a stray .env or a huge local folder quietly shipped into an image more than once. And the exec-form CMD note is easy to overlook until a deploy hangs because SIGTERM never reaches the app.
