title: docker-compose: difference between networks and links
body: <p>I'm learning docker. I see those two terms make me confuse. For example here is a docker-compose that defined two services <code>redis</code> and <code>web-app</code>.</p>
  
  <pre><code>services:
    redis:
      container_name: redis
      image: redis:latest
      ports:
        - "6379:6379"
      networks:
        - lognet
  
    app:
      container_name: web-app
      build:
        context: .
        dockerfile: Dockerfile
      ports:
        - "3000:3000"
      volumes:
        - ".:/webapp"
      links:
        - redis
      networks:
        - lognet
  
  networks:
    lognet:
      driver: bridge
  </code></pre>
  
  <p>This <code>docker-compose</code> file defines a bridge network named lognet and all services will connect to this network. As I understand, this action makes those services can see others. So why app service still need to link to redis service in above case.</p>
  
  <p>Thanks</p>