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.