Get Swarm node IP address from a container using API?

How to get the Swarm node IP address of just created container, using remote API?

  • Docker disk memory : can I remove intermediate images?
  • docker daemon -H fd:// error out in shell
  • PM2 Won't Start Inside Docker
  • Cannot connect to MySql in Docker. Access Denied Error thrown. Flask-SqlAlchemy
  • Docker restart entrypoint
  • docker version fails on OS X
  • Doubts about Docker with dcm4chee
  • Can't connect to MySQL container on AWS ECS
  • Running PhantomJS Selenium Node on Kubernetes
  • java.net.ConnectException when running test with Flyway and embedded Postgresql inside Docker container
  • Docker networking and ports
  • How to run a docker machine on homestead when port 80 is already in use?
  • One Solution collect form web for “Get Swarm node IP address from a container using API?”

    All relevant container information can be found with docker inspect <your container>.

    The IP of the node your container is running on can be obtained with

    docker inspect --format "{{ .Node.IP }}" <your container>
    

    Note however, that this might not be the publicly reachable IP address (on an AWS EC2 instance for example, where this would be a private IP).

    To get the hostname and port your swarm masters use to reach the node, use

    docker inspect --format "{{ .Node.Addr }}" <your container>
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.