According to the Docker Compose’s compose-file documentation:
depends_on
– Express dependency between services.links
– Link to containers in another service and also express dependency between services in the same way as depends_on.
I don’t understand the purpose of linking to other containers so the difference between two options still seems quite difficult for me.
It would be much easier if there is an example, but I can’t find any.
I noticed, when I link container B with container A then container B will be “pingable” inside container A’s shell.
I ran ping B
inside container A’s bash
and got result like this (just for reference, image from the Internet)