I have an obscure situation where I need to bind mount to a directory /foo/bar:baz
inside a container.
Attempting something like this doesn't work because the :
is interpreted as something other than part of the directory name:
services:
foo:
image: ...
volumes:
- "./source:/foo/bar:baz"
I feel like I must be missing something obvious in the documentation about how to escape the :
, but can't find it.
I have an obscure situation where I need to bind mount to a directory /foo/bar:baz
inside a container.
Attempting something like this doesn't work because the :
is interpreted as something other than part of the directory name:
services:
foo:
image: ...
volumes:
- "./source:/foo/bar:baz"
I feel like I must be missing something obvious in the documentation about how to escape the :
, but can't find it.
- Re: the close vote. Is docker-compose not a programming question anymore? – Philip Couling Commented Mar 28 at 15:55
1 Answer
Reset to default 1There is a less used version of the syntax that allows services
to be a map instead of single string: https://github/compose-spec/compose-spec/blob/main/05-services.md#volumes
services:
foo:
image: ...
volumes:
- type: bind
source: ./source
target: /foo/bar:baz