admin 管理员组

文章数量: 1086019

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.

Share Improve this question asked Mar 28 at 14:41 Philip CoulingPhilip Couling 15k8 gold badges71 silver badges98 bronze badges 1
  • Re: the close vote. Is docker-compose not a programming question anymore? – Philip Couling Commented Mar 28 at 15:55
Add a comment  | 

1 Answer 1

Reset to default 1

There 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

本文标签: How to bind mount to a path containing a colon () in docker composeStack Overflow