title: How to visit a docker service by ip address
body: <p>I'm new with <code>docker</code> and I'm probably missing a lot, although i went through the basic documentation and I'm trying to deploy a simple  <strong>Spring Boot API</strong> </p>
  
  <p>I've deployed my <strong>API</strong> as a <code>docker-spring-boot</code> <strong>.jar</strong> file , then i installed <code>docker</code> and pushed it with the following commands:</p>
  
  <ul>
  <li><code>sudo docker login</code></li>
  <li><code>sudo docker tag docker-spring-boot  phillalexakis/myfirstapi:01</code></li>
  <li><code>sudo docker push phillalexakis/myfirstapi:01</code></li>
  </ul>
  
  <p>Then i started the <strong>API</strong> with the docker <code>run</code> command:</p>
  
  <p><code>sudo docker run -p 7777:8085 phillalexakis/myfirstapi:01</code></p>
  
  <p>When i visit <strong>localhost:7777/hello</strong> I'm getting the desired <strong>response</strong></p>
  
  <p>This is my <code>Dockerfile</code> </p>
  
  <pre><code>FROM openjdk:8
  ADD target/docker-spring-boot.jar docker-spring-boot.jar
  EXPOSE 8085
  ENTRYPOINT ["java","-jar","docker-spring-boot.jar"]
  </code></pre>
  
  <p>Based on this <a href="https://stackoverflow.com/questions/17157721/how-to-get-a-docker-containers-ip-address-from-the-host">answered post</a> this the command to get the <code>ip address</code></p>
  
  <pre><code>docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id
  </code></pre>
  
  <p>So, i run it with <code>container_name_or_id = phillalexakis/myfirstapi:01</code> and I'm getting this error</p>
  
  <pre><code>Template parsing error: template: :1:24: executing "" at &lt;.NetworkSettings.Networks&gt;: map has no entry for key "NetworkSettings"
  </code></pre>
  
  <p>If i manage somehow to get the <code>IP</code> will i be able to visit it and get the same <strong>response</strong>?</p>
  
  <p>This is how i have it in my mind: <strong>ip:7777/hello</strong> </p>