I am using docker-compose, with a docker-compose.yml file.
Is there a way to get in .yml, the ID of another docker (which is in the same docker-compose.yml)?
docker-compose.yml:
containerA:
command: python -u catch_sig.py
volumes:
- /workspace:/app
containerB:
command: echo -e "POST /containers/containerA/kill?signal=SIGUSR1 HTTP/1.0\r\n" | nc -U /tmp/docker.sock
Find the running container's ID by using the docker ps command. Find the PID number of the first process in the running container by running the docker inspect command. Enter the running container by using the nsenter command.
The easiest way to list Docker images is to use the “docker images” with no arguments. When using this command, you will be presented with the complete list of Docker images on your system. Alternatively, you can use the “docker image” command with the “ls” argument.
In order to list the Docker containers, we can use the “docker ps” or “docker container ls” command. This command provides a variety of ways to list and filter all containers on a particular Docker engine.
With newer docker-compose versions (I have 1.8.0) you can do
$ docker-compose ps -q
Which will only display the id. See the usage.
$ docker-compose ps --help
List containers.
Usage: ps [options] [SERVICE...]
Options:
-q Only display IDs
You can get the ID of a container in this way:
docker-compose ps -q [container-name]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With