Consider the following YAML code in my
docker-compose.yml file that sets up volume mounting (using version 3.7), using short form syntax as specified in the docs:
volumes: - ./logging:/var/log/cron
This maps the relative path
logging on my host machine to the
/var/log/cron folder inside the container. When I run
docker-compose up , if the
logging folder doesn’t exist on my host machine, Docker creates it. All good there.
Now, if I change the above to long-form syntax:
volumes: - type: bind source: ./logging target: /var/log/cron
Now when I run
docker-compose up , it DOES NOT create
logging folder if it doesn’t exist on my host machine. I get
Cannot create container for service app: b'Mount denied:\nThe source path "C:/Users/riptusk331/logging"\ndoesn\'t exist and is not known to Docker'
Does anyone know why the short form syntax creates the host path if it doesn’t exist, but the long form does not and gives an error?
I’m posting here more-so because I’m just genuinely curious about what the difference is that causes this behavior.