title: how to link docker container to each other with docker-compose
body: <p>I have to setup a mongo replica set with docker-compose. For the replica set the containers have to know each other.</p>
  
  <p>I tried in <code>docker-compose.yml</code></p>
  
  <pre><code>    dbreplicasetpart1:
        image: mongo:2.6.8
        expose:
          - '27018'
        links:
          - replicasetpart2
          - replicasetpart3
        cap_add:
          - NET_ADMIN
  
      dbreplicasetpart2:
        image: mongo:2.6.8
        links:
          - replicasetpart1
          - replicasetpart3
        expose:
          - '27019'
        cap_add:
          - NET_ADMIN
  ...
  </code></pre>
  
  <p>I get an circular import message. But if I remove the back-link to dbreplicasetpart1 I can't ping from dbreplicasetpart2 to dbreplicasetpart1.
  What is the solution?</p>