중급 Docker
Mike Metzger
Data Engineering Consultant
postgresql이 먼저 시작되어야 함
postgresql이 먼저 시작python_app
postgresql이 먼저 시작python_appnginx 웹 서버
depends_on 속성으로 종속성 정의compose.yaml의 순서는 중요하지 않음services: postgresql: image: postgresql:latestpython_app: image: custom_app depends_on: - postgresqlnginx: image: nginx/latest depends_on: - python_app
nginx 리소스를 먼저 중지
nginx 리소스를 먼저 중지python_app 리소스를 중지
nginx 리소스를 먼저 중지python_app 리소스를 중지postgresql 리소스를 중지
condition:은 리소스 준비 완료 판단 기준을 정의service_started - 리소스가 정상 시작됨service_completed_successfully - 초기 구성 등 작업이 완료됨service_healthy - healthcheck 기준을 충족함services: nginx: image: nginx/latest depends_on: python_app: condition: service_startedpython_app: image: custom_app depends_on: postgresql: condition: service_healthy
docker compose logs - 애플리케이션의 모든 리소스 출력을 수집redis-1 | * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-1 | * Running mode=standalone, port=6379.
redis-1 | * Server initialized
redis-1 | * Ready to accept connections tcp
web-1 | * Serving Flask app 'app.py'
web-1 | * Running on all addresses (0.0.0.0)
web-1 | * Running on http://172.20.0.2:5000
web-1 | Press CTRL+C to quit
docker compose logs <resourcename>docker compose top은 애플리케이션 내 리소스 상태를 표시composetest-redis-1
UID PID PPID C STIME TTY TIME CMD
999 2767 2726 0 01:16 ? 00:03:27 redis-server *:6379
composetest-web-1
UID PID PPID C STIME TTY TIME CMD
root 2768 2740 0 01:16 ? 00:00:23 /usr/local/bin/python /usr/local/bin/flask run
중급 Docker