title: Cannot connect to mongo container
body: <p>I had a previous question that (I think at least) that more or less became useless as I managed to fix the errors I was presented with.. However my new error, is that I cannot seem to connect to mongodb from within my docker image</p>
  
  <p>docker-compose.yml:</p>
  
  <pre><code>version: '3.1'
  services:
    company-repo-docker-app:
      image: company-repo-image
      build:
          context: ./
      dockerfile: Dockerfile
      depends_on:
          - mongo
  ports:
      - 8080:8080
  mongo:
  image: mongo
  ports:
    - '27017:27017'
  networks:
    mongo_net:
      ipv4_address: 172.28.0.2
  
  networks:
    mongo_net:
      driver: bridge
      ipam:
        driver: default
        config:
        -
         subnet: 172.28.0.2/24
  </code></pre>
  
  <p>application.properties:</p>
  
  <pre><code>spring.data.mongodb.database=myDb
  spring.data.mongodb.host=172.28.0.2 
  spring.data.mongodb.port=27017
  </code></pre>
  
  <p>And the actual error:</p>
  
  <pre><code> com.mongodb.MongoSocketOpenException: Exception opening socket
     at com.mongodb.connection.SocketStream.open(SocketStream.java:62) ~[mongodb-driver-core-3.6.4.jar!/:na]
     at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:126) ~[mongodb-driver-core-3.6.4.jar!/:na]
     at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:114) ~[mongodb-driver-core-3.6.4.jar!/:na]
     at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]
  Caused by: java.net.SocketTimeoutException: connect timed out 
  </code></pre>