Docker और Compose चीटशीट
Docker 27+ पर कंटेनर लाइफ़साइकल, इमेज बिल्ड, मल्टी-स्टेज Dockerfile, Compose v2 स्टैक, नेटवर्किंग, वॉल्यूम, लॉग और सुरक्षित क्लीनअप कमांड।
यह कैसे काम करता है
Images are immutable layered templates; containers are writable runtime processes from an image; volumes persist state across container replacement; networks wire service DNS.
सर्वाइवल किट
वे कुछ कमांड जिन्हें सबसे पहले सीखना चाहिए।
42 कमांड
Run & Inspect Containers
Start containers, map ports, inspect logs, and attach interactive shells.
- आवश्यक
Start an ephemeral interactive container and delete it on exit
docker run --rm -it <image> <shell>कमांड बनाएँ
docker run --rm -it <image> <shell>मान ठीक वैसे ही डाले जाते हैं जैसे टाइप किए गए हैं। यदि उनमें स्पेस या विशेष वर्ण हों तो स्वयं उद्धरण चिह्न लगाएँ।
इसका उपयोग कब करें
Best for throwaway debugging environments without leaving stopped containers behind.
घटक विवरण
- --rm
- Automatically remove container once it exits
- -it
- Interactive stdin (-i) + pseudo-TTY (-t)
उदाहरण
docker run --rm -it alpine:3.20 sh
Images & Multi-Platform Builds
Build, tag, inspect image layers, and manage local registries.
Docker Compose v2
Orchestrate multi-container local stacks cleanly with `docker compose`.
Volumes, Networks & Files
Persist database state, connect containers by service name, and copy files.
Disk Usage & Safe Cleanup
Measure disk consumption and prune unused objects without losing data.