I would like to retrieve the name of a container or id (called data
for example) from running containers started with docker-compose.
I need it to be able to backup volume inside this container with this command for example:
docker run --volumes-from DATA_CONTAINER_NAME -v $(pwd):/backups ubuntu tar zcvf /backups/backup.tar.gz /var/lib/mysql /var/www/html
Thank you
Was just looking to do the same thing - solved it by getting the container ID with
docker-compose ps -q data
Sometime things are just simple :-)
Thanks dude
If someone is looking for get the internal ip address of the container. using kmontag answer iam using:
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker-compose ps -q sentry)
And if someone needs the name:
docker inspect -f '{{.Name}}' $(./devbox docker-compose ps -q data) | cut -c2-
Most helpful comment
Was just looking to do the same thing - solved it by getting the container ID with