Compose: Retrieve the name or id of a container

Created on 7 Apr 2015  路  4Comments  路  Source: docker/compose

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

Most helpful comment

Was just looking to do the same thing - solved it by getting the container ID with

docker-compose ps -q data

All 4 comments

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-
Was this page helpful?
0 / 5 - 0 ratings