C.W.K.
Stream
Lesson 06 of 13 · published

Docker-in-Docker

~9 min · docker, dind, isolation

Level 0Apprentice
0 XP0/101 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

컨테이너 안에서 컨테이너 빌드

Hosted runner 는 Docker 미리 설치. Self-hosted, 특히 runner 자체 컨테이너화 시 runner 안에서 Docker 명령 돌리는 전략 필요.

세 패턴

  1. 호스트 Docker socket 마운트/var/run/docker.sock 을 runner 에. 가장 쉬움. 안전 안 함: job 이 host 로 탈출 가능.
  2. Docker-in-Docker (dind) — runner 안에 별도 Docker daemon 실행. 더 안전; 더 느림; --privileged 또는 rootless dind 필요.
  3. Buildkit 단독 — image 빌드만이면 Buildkit 이 dockerd 없이 실행 가능. 슬림 + 빠름.

권장

  • 신뢰 코드: socket 마운트 OK, 쉽고 빠름.
  • 신뢰 안 되는 코드: rootless dind 또는 Kaniko/Buildkit.
  • Apple Silicon: Mac 의 Docker Desktop 이 daemon 처리; runner agent 가 정상 대화.

Code

마운트된 Docker socket 가진 runner·yaml
# docker-compose.yml for self-hosted runner
services:
  runner:
    image: ghcr.io/myorg/runner:latest
    environment:
      RUNNER_TOKEN: ${RUNNER_TOKEN}
      RUNNER_REPOSITORY_URL: https://github.com/my-org/my-repo
      RUNNER_LABELS: self-hosted,linux-x64,docker
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - runner-cache:/home/runner
    restart: unless-stopped

volumes:
  runner-cache:

External links

Exercise

Self-hosted runner 가 Docker image 빌드하면 오늘 Docker 어떻게 하는지 분류: socket 마운트, dind, Buildkit, 아니면 다른 거. 도는 코드의 신뢰 계층에 매칭. 필요하면 마이그레이션.

Progress

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

댓글 0

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

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