title: Access to mongodb container from another host with container ip
body: <p>I've created a mongodb container in docker with this command:</p>
  
  <p>from host1:</p>
  
  <pre><code>docker run -p 27017:27017 mongo --bind_ip_all
  </code></pre>
  
  <p>I know host1.ip.</p>
  
  <p>I find out container id with:</p>
  
  <pre><code>docker inspect &lt;mongo_id&gt;
  </code></pre>
  
  <p>For example container.ip = 172.17.0.2</p>
  
  <p>From host2</p>
  
  <p>if I run:</p>
  
  <pre><code>mongo --host: &lt;host1.ip&gt;:27017 
  </code></pre>
  
  <p>it works</p>
  
  <p>But if run</p>
  
  <pre><code>mongo --host: 172.17.0.2:27017 
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>MongoDB shell version v3.6.3
    connecting to: mongodb://172.17.0.2:27017/
    2018-06-20T13:54:17.111+0200 W NETWORK  [thread1] Failed to connect to 172.17.0.2:27017, in(checking socket for error after poll), reason: No route to host
    2018-06-20T13:54:17.111+0200 E QUERY    [thread1] Error: couldn't connect to server 172.17.0.2:27017, connection attempt failed :
    connect@src/mongo/shell/mongo.js:251:13
    @(connect):1:6
    exception: connect failed</p>
  </blockquote>
  
  <p>I'd know why it doesn't work and what i can do to manage that</p>