docker/compose

sort output of `docker compose up -d` by name

trim21 opened this issue · 4 comments

Description

currently the output of up -d is unstable, proposal to add sort by services name (when possible)

after reading the code I fine that they service here are InDependencyOrder, but it's not stable if services doesn't have dependency graph.

Hello @trim21

What do you mean by unstable?
docker up -d only display build and containers creation steps.
docker up will also display container logs but as containers are running in parallel logs can be mixed in the output, that why logs are prefixed by the container service name like:

api-1  |  * Debugger PIN: 703-580-771
web-1  | yarn run v1.22.22

If you want to focus on a specific service log you can use docker compose logs your-service-name

I mean docker compose up -d (does docker also have a up command? i'm sorry for the confusion)

for example, the first run:

[+] Running 3/0
 ✔ Container chii-pg-patch-1  Running                                  0.0s
 ✔ Container chii-pg-1        Running                                  0.0s
 ✔ Container chii-backup-1    Running                                  0.0s

the second run:

[+] Running 3/0
 ✔ Container chii-pg-1        Running                                  0.0s
 ✔ Container chii-pg-patch-1  Running                                  0.0s
 ✔ Container chii-backup-1    Running                                  0.0s

the order of container here is randomized.

I'm suggesting to show container status in some kind of order, by service name maybe.

After reading the code, looks like this is currently not very doable?

The services without dependency relation will startup in parallel, add such feature will slowdown the startup process or need to change the output message, which will cause too much trouble.