title: Difference between links and depends_on in docker_compose.yml
body: <p>According to the Docker Compose's <a href="https://docs.docker.com/compose/compose-file" rel="noreferrer">compose-file documentation</a>:</p>
  
  <ul>
  <li><code>depends_on</code> - Express dependency between services.</li>
  <li><code>links</code> - Link to containers in another service and also <strong>express dependency between services</strong> in the same way as <a href="https://docs.docker.com/compose/compose-file/#depends-on" rel="noreferrer">depends_on</a>.</li>
  </ul>
  
  <p>I don't understand the purpose of linking to other containers so the difference between two options still seems quite difficult for me.</p>
  
  <p>It would be much easier if there is an example, but I can't find any.</p>
  
  <p>I noticed, when I link container B with container A then container B will be "pingable" inside container A's shell.</p>
  
  <p>I ran <code>ping B</code> inside container A's <code>bash</code> and got result like this (just for reference, image from the Internet)</p>
  
  <p><a href="https://i.stack.imgur.com/DI9Io.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/DI9Io.jpg" alt="enter image description here"></a></p>