How to pass the result of a command to docker inspect format (Golang template)?

I’m trying to pass the result of a command to the golang template of another command:

container_id=$(docker ps -aqf “name=container_name“)

  • How to access boot2docker-ip from inside a docker container
  • List containers in the same docker-compose
  • How can I connect celery container to rabbitmq container when using --net=host?
  • How to create env-file in centos 7 for docker
  • Docker run with “-v” create another shared directory
  • Can't attach to bash running the Docker container
  • docker network inspectformat='{{range $i,$container:= .Containers}} {{if eq $container.Name (print ‘gateway_’ $container_id)}} {{$container.IPv4Address}} {{end}} {{end}}’ network

    The purpose is to get the container IP Address in the specific network interface, which is not available with a simple

    docker inspect container_id

    Thank you for any help.

  • Canonical way to checksum downloads in a Dockerfile?
  • Is docker a possible solution to ruby GIL limitation in rails?
  • Docker, Nginx and PHP7: ERROR 111 Connection refused while connecting to upstream
  • MessageListenerContainer not listening after crashing master redis instance in redis sentinel in docker env
  • Retain environment variable values for Symfony2 app development in Docker
  • Docker + Django + MySQL - End of list of non-natively partitioned tables
  • One Solution collect form web for “How to pass the result of a command to docker inspect format (Golang template)?”

    You need to use " and escape all other $ used by golang template. The following command will print IPv4 Address by container name on interface bridge:

    $> export CONTAINER_NAME=backstabbing_feynman
    $> docker network inspect --format="{{range \$id, \$container := .Containers}} {{if eq \$container.Name \"$CONTAINER_NAME\"}} {{\$id}} -> {{\$container.IPv4Address}} {{end}}{{end}}"  bridge
    3a77b8fe2d14fb527a8c634fdaa46121672daf827c7fad0aabad1de37877e03e ->

    Using container_id will be the similiar.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.