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?

  • Hostname for website running inside Docker
  • Add entries to containers /etc//hosts When spinning up a pod with pod1.yaml or pod1.json
  • Docker + Weave dns not resolving on other host
  • Configure Docker Container to receive messages via port not working as expected
  • Install Docker auto completion without using Home Brew
  • Convert “docker run …” into “docker create …” && “docker start …”
  • Git to docker export
  • Implementing Simulation application using AKKA
  • How to access Consul used in Docker overlay networks?
  • Pulling image from local docker insecured Docker registry to Kubernetes
  • Launch Docker Container using ansible-playbook from a locally available docker image
  • Attempting to use docker-client from Spotify and am getting various errors
  • 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.