docker 사전 준비사항

허동빈·2026년 1월 27일

docker

목록 보기
2/8
post-thumbnail

Chapter 02: 사전 준비사항

Docker 컨테이너화에 필요한 모든 도구를 설치하고 환경 구성.


1. 필수 소프트웨어 개요

설치할 도구들

도구역할설치 위치필수 여부
Docker Desktop컨테이너 런타임Native✅ 필수
Git소스 코드 버전 관리Native✅ 필수
K6부하 테스트 도구Native✅ 필수
Prometheus메트릭 수집Native✅ 필수
Grafana대시보드 시각화Native✅ 필수
JDK 21(참고) Docker 빌드 시 필요 없음-❌ 불필요*

참고: JDK는 Dockerfile 내부에서 자동으로 다운로드되므로 로컬에 설치 불필요합니다.

💾 디스크 공간 요구사항

  • 최소: 10GB
  • 권장: 20GB 이상

이유:

  • Docker Desktop: ~5GB
  • Docker 이미지들: ~3GB
  • 프로젝트 소스: ~500MB
  • Prometheus 데이터: ~1GB
  • 여유 공간: ~10GB

2. Docker Desktop 설치

🍎 macOS 설치

2-1. Docker Desktop 다운로드

방법 1: 공식 웹사이트 (권장)

  1. 브라우저에서 접속:

    https://www.docker.com/products/docker-desktop
  2. "Download for Mac" 버튼 클릭

  3. 칩셋 선택:

    • M1/M2/M3 (Apple Silicon): Mac with Apple chip 다운로드
    • Intel: Mac with Intel chip 다운로드

방법 2: Homebrew

# Homebrew로 설치 (터미널)
brew install --cask docker

2-2. 설치 및 실행

  1. 다운로드한 Docker.dmg 파일 실행
  2. Docker.appApplications 폴더로 드래그
  3. Launchpad에서 Docker 아이콘 클릭 실행
  4. 처음 실행 시 권한 요청 → "확인" 클릭
  5. Docker Desktop이 실행될 때까지 대기 (상단 메뉴바에 고래 아이콘 표시)

2-3. 설정 확인

Docker Desktop 아이콘 클릭 → Settings (⚙️)

Resources 설정:

CPU: 4개 이상 권장
Memory: 4GB 이상 권장 (최소 3GB)
Swap: 1GB
Disk: 60GB

중요: 메모리가 4GB 미만이면 컨테이너가 OOM으로 종료될 수 있습니다.

2-4. 설치 검증

터미널을 열고 실행:

# Docker 버전 확인
docker --version
# 출력 예시: Docker version 24.0.6, build ed223bc

# Docker Compose 버전 확인
docker compose version
# 출력 예시: Docker Compose version v2.23.0

# Docker 실행 테스트
docker run hello-world

성공 시 출력:

Hello from Docker!
This message shows that your installation appears to be working correctly.
...

🪟 Windows 설치

2-1. WSL 2 설치 (필수)

Docker Desktop on Windows는 WSL 2를 백엔드로 사용합니다.

PowerShell을 관리자 권한으로 실행:

# WSL 설치
wsl --install

# 컴퓨터 재시작

재시작 후 Ubuntu 사용자 설정:

  • 사용자 이름 입력
  • 비밀번호 입력 (2회)

2-2. Docker Desktop 다운로드

  1. 브라우저에서 접속:

    https://www.docker.com/products/docker-desktop
  2. "Download for Windows" 버튼 클릭

  3. Docker Desktop Installer.exe 다운로드

2-3. 설치 및 실행

  1. 다운로드한 .exe 파일 실행
  2. "Use WSL 2 instead of Hyper-V" 옵션 체크 ✅
  3. 설치 진행
  4. 설치 완료 후 재시작
  5. Docker Desktop 실행 (바탕화면 아이콘)
  6. 서비스 약관 동의
  7. Docker Desktop이 실행될 때까지 대기 (트레이에 고래 아이콘)

2-4. 설정 확인

Docker Desktop 아이콘 우클릭 → Settings

Resources > WSL Integration:

  • ✅ Enable integration with my default WSL distro
  • ✅ Ubuntu 체크

Resources:

CPU: 4개 이상 권장
Memory: 4GB 이상 권장
Swap: 1GB
Disk: 60GB

2-5. 설치 검증

PowerShell 또는 CMD 실행:

# Docker 버전 확인
docker --version

# Docker Compose 버전 확인
docker compose version

# Docker 실행 테스트
docker run hello-world

3. K6 설치

🍎 macOS - K6 설치

방법 1: Homebrew (권장)

# K6 설치
brew install k6

# 검증
k6 version
# 출력: k6 v0.48.0

방법 2: 바이너리 다운로드

# Intel Mac
curl -L https://github.com/grafana/k6/releases/download/v0.48.0/k6-v0.48.0-macos-amd64.zip -o k6.zip

# Apple Silicon (M1/M2/M3)
curl -L https://github.com/grafana/k6/releases/download/v0.48.0/k6-v0.48.0-macos-arm64.zip -o k6.zip

# 압축 해제
unzip k6.zip

# 실행 권한 부여
chmod +x k6

# /usr/local/bin으로 이동
sudo mv k6 /usr/local/bin/

# 검증
k6 version

🪟 Windows - K6 설치

방법 1: Chocolatey (권장)

# Chocolatey로 설치 (관리자 권한 PowerShell)
choco install k6

# 검증
k6 version

방법 2: winget

# winget으로 설치
winget install k6 --source winget

# 검증
k6 version

방법 3: 수동 설치

  1. https://github.com/grafana/k6/releases 접속
  2. k6-v0.48.0-windows-amd64.zip 다운로드
  3. 압축 해제
  4. k6.exeC:\Program Files\k6\ 폴더로 이동
  5. 시스템 환경 변수 PATH에 추가:
    • 제어판 → 시스템 → 고급 시스템 설정
    • 환경 변수 → Path 편집
    • C:\Program Files\k6 추가

검증 (PowerShell):

k6 version

5. Prometheus 설치

🍎 macOS - Prometheus 설치

방법 1: Homebrew (권장)

# Prometheus 설치
brew install prometheus

# 검증
prometheus --version
# 출력: prometheus, version 2.47.0

# 기본 설정 파일 위치 확인
ls $(brew --prefix)/etc/prometheus.yml

방법 2: 수동 설치

# 다운로드 (최신 버전 확인: https://prometheus.io/download/)
# Intel Mac
curl -LO https://github.com/prometheus/prometheus/releases/download/v2.47.0/prometheus-2.47.0.darwin-amd64.tar.gz

# Apple Silicon
curl -LO https://github.com/prometheus/prometheus/releases/download/v2.47.0/prometheus-2.47.0.darwin-arm64.tar.gz

# 압축 해제
tar -xzf prometheus-*.tar.gz

# 이동
mv prometheus-2.47.0.darwin-* ~/prometheus

# 디렉토리 이동
cd ~/prometheus

# 검증
./prometheus --version

🪟 Windows - Prometheus 설치

수동 설치:

  1. https://prometheus.io/download/ 접속
  2. Windows 섹션에서 prometheus-2.47.0.windows-amd64.zip 다운로드
  3. 압축 해제 → C:\prometheus 폴더로 이동

검증 (PowerShell):

cd C:\prometheus
.\prometheus.exe --version

📝 Prometheus 설정 파일 생성 (공통)

prometheus.yml 파일 생성:

# macOS (Homebrew 설치 시)
cd $(brew --prefix)/etc
nano prometheus.yml

# macOS (수동 설치 시)
cd ~/prometheus
nano prometheus.yml

# Windows
cd C:\prometheus
notepad prometheus.yml

prometheus.yml 내용:

global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
  # Spring Boot Actuator
  - job_name: 'spring-boot'
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['localhost:8080']
        labels:
          application: 'auction-app'
          environment: 'docker-dev'

  # Prometheus 자기 자신
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

저장:

  • macOS nano: Ctrl + XYEnter
  • Windows notepad: Ctrl + S

6. Grafana 설치

🍎 macOS - Grafana 설치

방법 1: Homebrew (권장)

# Grafana 설치
brew install grafana

# 검증
grafana-server -v
# 출력: Version 10.2.0

방법 2: 수동 설치

# Intel Mac
curl -LO https://dl.grafana.com/oss/release/grafana-10.2.0.darwin-amd64.tar.gz

# Apple Silicon
curl -LO https://dl.grafana.com/oss/release/grafana-10.2.0.darwin-arm64.tar.gz

# 압축 해제
tar -xzf grafana-*.tar.gz

# 이동
mv grafana-10.2.0 ~/grafana

# 검증
cd ~/grafana
./bin/grafana-server -v

🪟 Windows - Grafana 설치

방법 1: Chocolatey

# 관리자 권한 PowerShell
choco install grafana

# 검증
grafana-server.exe -v

방법 2: 수동 설치

  1. https://grafana.com/grafana/download 접속
  2. Windows 탭 → ZIP 파일 다운로드
  3. 압축 해제 → C:\grafana 폴더로 이동

검증:

cd C:\grafana\bin
.\grafana-server.exe -v

7. 설치 검증

✅ 전체 도구 버전 확인

macOS

# 한 번에 확인
echo "=== Docker ==="
docker --version
docker compose version

echo -e "\n=== Git ==="
git --version

echo -e "\n=== K6 ==="
k6 version

echo -e "\n=== Prometheus ==="
prometheus --version

echo -e "\n=== Grafana ==="
grafana-server -v

Windows (PowerShell)

# 한 번에 확인
Write-Host "=== Docker ===" -ForegroundColor Green
docker --version
docker compose version

Write-Host "`n=== Git ===" -ForegroundColor Green
git --version

Write-Host "`n=== K6 ===" -ForegroundColor Green
k6 version

Write-Host "`n=== Prometheus ===" -ForegroundColor Green
& "C:\prometheus\prometheus.exe" --version

Write-Host "`n=== Grafana ===" -ForegroundColor Green
& "C:\grafana\bin\grafana-server.exe" -v

🧪 Docker 테스트

공통 (Mac/Windows)

# 1. Hello World 테스트
docker run hello-world

# 2. MySQL 컨테이너 실행 (기존 컨테이너 확인)
docker ps | grep mysql
# 출력 예시: mysql-1   mysql   Up 2 hours   0.0.0.0:3306->3306/tcp

# 3. Redis 컨테이너 실행 (기존 컨테이너 확인)
docker ps | grep redis
# 출력 예시: redis-auction   redis:7-alpine   Up 2 hours   0.0.0.0:6379->6379/tcp

만약 MySQL/Redis가 없다면:

# MySQL 컨테이너 생성
docker run -d \
  --name mysql-1 \
  --restart unless-stopped \
  -p 3306:3306 \
  -e MYSQL_ROOT_PASSWORD=your_password \
  -e MYSQL_DATABASE=DevCourse \
  -v mysql-data:/var/lib/mysql \
  mysql:8.0

# Redis 컨테이너 생성
docker run -d \
  --name redis-auction \
  --restart unless-stopped \
  -p 6379:6379 \
  -v redis-data:/data \
  redis:7-alpine

📊 모니터링 도구 테스트

Prometheus 시작 테스트

macOS:

# Homebrew 설치 시
brew services start prometheus

# 수동 설치 시
cd ~/prometheus
./prometheus --config.file=prometheus.yml \
  --web.enable-remote-write-receiver \
  --storage.tsdb.path=./data &

Windows:

cd C:\prometheus
Start-Process -FilePath ".\prometheus.exe" `
  -ArgumentList "--config.file=prometheus.yml","--web.enable-remote-write-receiver" `
  -WindowStyle Hidden

검증:

브라우저에서 접속:

http://localhost:9090

Prometheus UI가 보이면 성공

중지 (테스트 후):

# macOS (Homebrew)
brew services stop prometheus

# macOS (수동) / Windows
pkill prometheus  # macOS
# Windows: 작업 관리자에서 prometheus.exe 종료

Grafana 시작 테스트

macOS:

# Homebrew 설치 시
brew services start grafana

# 수동 설치 시
cd ~/grafana
./bin/grafana-server &

Windows:

cd C:\grafana\bin
Start-Process -FilePath ".\grafana-server.exe" -WindowStyle Hidden

검증:

브라우저에서 접속:

http://localhost:3000
  • 기본 계정: admin / admin
  • 첫 로그인 시 비밀번호 변경 요청

중지 (테스트 후):

# macOS (Homebrew)
brew services stop grafana

# macOS (수동) / Windows
pkill grafana  # macOS
# Windows: 작업 관리자에서 grafana-server.exe 종료

🐛 문제 해결

Docker Desktop이 시작되지 않음

macOS:

# Docker Desktop 완전 재설치
brew uninstall --cask docker
brew install --cask docker

Windows:

  • WSL 2 상태 확인: wsl --status
  • WSL 업데이트: wsl --update

K6가 인식되지 않음 (Windows)

PATH 환경 변수 확인:

$env:Path -split ';' | Select-String k6

출력이 없으면 PATH 추가 필요.


Prometheus/Grafana 포트 충돌

포트 사용 확인:

# macOS
lsof -i :9090  # Prometheus
lsof -i :3000  # Grafana

# Windows
netstat -ano | findstr :9090
netstat -ano | findstr :3000

📚 참고 자료


profile
백엔드 공부

0개의 댓글