Search code examples
dockerdocker-composevolumes

Docker-compose.yaml - difference between single line volumes declaration and bind type declaration


Apologies if this is a dumb question but...

I am still getting to understand docker, but can't seem to find an answer to when you would use one of the following over the other in a docker-compose.yaml file:

e.g.

      volumes:
        - type: bind
          source: /c/docker/tool/log
          target: /opt/distribution/log

OR

volumes: 
            - "c:/docker/tool/log:/opt/distribution/log"

Are the above two snippets equivalent to each other? They appear to do the same job - but I am not sure if I am missing some key points with the bind version.


Solution

  • You are on the right track. There always is a long version where you can define all parameters in detail and there is a short track that allows you to mount a volume with default settings. Refer to the documentation. The doc always lists both options. https://docs.docker.com/compose/compose-file/compose-file-v3/#volumes