There is a smart way to get the list of services (or containers) of docker-compose files from inside of a container.
I would prefer not to using volumes, or passing statically the compose-file to container and parse it or pass a list with these infromations from environment variable.
One perfect result is given by docker-compose config --service
,
that returns the list of all services of compose but I don't know how to pass it to my container from the host.
(I would like get the list of all containers that they compose my application so I can monitor which go up and down with using registrator and consul).
Please follow the instruction:
brew install yq
.docker-compose config | yq '.services[]|key'
ordocker compose config | yq '.services[]|key'
.you will find the list of all available services.