title: I can't connect to my mongo docker container by its name
body: <p>I'm pretty new to docker but I'm having some issues getting a node app to connect to a mongo database running on a separate container.  </p>
  
  <p>I'm using the <a href="https://hub.docker.com/_/mongo/" rel="nofollow noreferrer">official mongo image</a></p>
  
  <p>I run it using:</p>
  
  <pre><code>docker run --name some-mongo --network-alias some-mongo -d mongo
  </code></pre>
  
  <p>It's running on port 27017 by default. I can connect to it using the mongo shell:</p>
  
  <pre><code>mongo --host mongodb://172.17.0.2:27017
  </code></pre>
  
  <p>But I can't connect to it by name</p>
  
  <pre><code>mongo --host mongodb://some-mongo:27017
  
  MongoDB shell version: 3.2.19
  connecting to: mongodb://some-mongo:27017/test
  2018-05-07T17:23:20.813-0400 I NETWORK  [thread1] getaddrinfo("some-mongo") failed: Name or service not known
  2018-05-07T17:23:20.813-0400 E QUERY    [thread1] Error: couldn't initialize connection to host some-mongo, address is invalid :
  connect@src/mongo/shell/mongo.js:223:14
  @(connect):1:6
  exception: connect failed
  </code></pre>
  
  <p>Instead I get an error message about how I can't connect to the mongo host:</p>
  
  <p>I'm trying some docker-compose tutorials but either they're too simple or they don't seem to work for me. I just want to connect a custom node app, (not the official node) to mongodb and some other dependencies.  </p>