In short:
volumes_frommounts from other containers.volumesmounts defined inline.linksconnects containers.
A little bit more explained:
-
volumes_frommounts volumes from other containers. For example if you have data only containers and you want to mount these data only containers in the container that has your application code. -
volumesis a the inline way to define and mount volumes. If you read #17798 you can see that named volumes can replace data only containers in most cases.The simplest is then to use volumes. Since you can reuse them by naming them.
-
linksis different. Because it does not mount. Instead it connects containers. So if you do:app: container_name: app_container links: - dbThat means that if you connect to
app_containerwithdocker exec -it app_container bashand tryping dbyou will see that container is able to resolve ip for db.This is because docker creates a network between containers.