最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to bind mount to a path containing a colon (:) in docker compose - Stack Overflow

programmeradmin0浏览0评论

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
发布评论

评论列表(0)

  1. 暂无评论