Lets say I have 3 containers X,Y and Z. I want container Y to start only after container X is running, and container Z to start only after Y is running.
How do I do this?
You can use docker-compose
file with the depends_on
option to control container start order
Here is how the docker-compose.yml
for your example would look like:
version: '3'
services:
X:
image: X_image
Y:
image: Y_image
depends_on: X
Z:
image: Z_image
depends_on: Y
Note:
depends_on
will not wait for X to be “ready” before starting Y - only until it's running. If you need to wait for a service to be ready, see Controlling startup order for more on this problem and strategies for solving it.
You should consider to redesign your application parts if they have such heavy dependencies, then they should maybe not be split to different containers or you should use some decoupeling to avoid
What you could do is to: