docker-compose get ID of a docker

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 run with ENTRYPOINT containing a variable
  • How to delete a user from the LDAP container
  • Docker: Connectivity between Physical Machine - VM -Docker container
  • Hadoop Cluster distributed in different sub-networks (Docker + Flannel)
  • How do I run a salt state on a running docker container
  • sbt only fetch dependencies
  • docker-compose.yml:

      command: python -u 
        - /workspace:/app
      command: echo -e "POST /containers/containerA/kill?signal=SIGUSR1 HTTP/1.0\r\n" | nc -U /tmp/docker.sock

  • Router assign ip to docker container
  • force a docker build to 'rebuild' a single step
  • How to manage inter-dependant docker containers when moving between or cloning environments
  • Test nodejs application with selenium
  • How to find dependencies before installing a PHP extension with Docker
  • Install gems on docker
  • 3 Solutions collect form web for “docker-compose get ID of a docker”

    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...]
       -q    Only display IDs

    Not sure about the .yml file but if you link the containers you can get the ID from /etc/hosts as written in the docs. Maybe this will be helpful.

    You can add the Docker client to containerB and then set the DOCKER_HOST environment to the underlying host (be sure to configure its settings so it accepts TCP connections on the network). Then, you can do a docker inspect containerA using the container name to identify the host you are querying.

    This should give you the container id for containerA.

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