C.W.K.
Stream
Lesson 02 of 05 · published

스토리지 셋 — Volume, bind mount, tmpfs

~14 min · data, concepts

Level 0Container 호기심
0 XP0/36 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Docker 는 영속성 메커니즘 셋 줘

타입저장 위치용도
Named volume호스트의 Docker 관리 영역 (/var/lib/docker/volumes/)Production 데이터, DB, Docker 가 소유해야 하는 모든 거
Bind mount호스트 filesystem 의 아무 경로Dev (소스 마운트, hot-reload), config 파일, 공유 디렉토리
tmpfs mountRAM (호스트 메모리)Secret, 빠른 스크래치, 디스크에 절대 안 닿아야 하는 모든 거

빠른 문법

Code

Flag 셋, 메커니즘 셋·bash
# Named volume (Docker-managed)
docker run -d -v pgdata:/var/lib/postgresql/data postgres:16

# Bind mount (host path → container path)
docker run -it --rm -v $(pwd)/src:/app/src python:3.12 sh

# tmpfs (RAM-only)
docker run -d --tmpfs /app/cache:size=100m,mode=1777 myapp
새 --mount 문법 (더 명시적)·bash
docker run -d \
  --mount type=volume,source=pgdata,target=/var/lib/postgresql/data \
  --mount type=bind,source=$(pwd)/config.yaml,target=/app/config.yaml,readonly \
  --mount type=tmpfs,target=/app/cache,tmpfs-size=104857600 \
  myapp

# More verbose, but every option is explicit. Compose files use this shape.

External links

Exercise

같은 Postgres container 두 번 돌려 — 한 번은 ~/pgdata 에 bind mount, 한 번은 named volume pgdata 로. 각각 데이터 입력. docker volume inspect (named) 와 ls (bind path) 로 포인터 경로 옮겨봐. 어느 게 백업하기 쉬워? 어느 게 다른 호스트로 옮기기 쉬워?

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.