Intermediate Docker
Mike Metzger
Data Engineering Consultant
postgresql must start first
postgresql must start firstpython_app
postgresql must start firstpython_appnginx web server
depends_on attributecompose.yaml file does not matterservices: postgresql: image: postgresql:latestpython_app: image: custom_app depends_on: - postgresqlnginx: image: nginx/latest depends_on: - python_app
nginx resource
nginx resourcepython_app resource
nginx resourcepython_app resourcepostgresql resource
condition: defines how to decide when resource is ready.service_started - Resource has started normallyservice_completed_successfully - Resource ran to completion, such as a initial configuration / etcservice_healthy - Resource meets a criteria defined by healthcheckservices: nginx: image: nginx/latest depends_on: python_app: condition: service_startedpython_app: image: custom_app depends_on: postgresql: condition: service_healthy
docker compose logs - Gathers output from all resources in applicationredis-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 shows status of resources within an applicationcomposetest-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
Intermediate Docker