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

Docker compose bind mount with colon and comma in path - Stack Overflow

programmeradmin2浏览0评论

I have mounted my google drive folder in Ubuntu using gnome-online-accounts, which ends up being mounted like so:

/run/user/1000/gvfs/google-drive:host=my_host,user=my.username

Mounting this in a docker container works fine if I escape it correctly, i.e.:

--mount "type=bind,\"source=/run/user/1000/gvfs/google-drive:host=my_host,user=my.username/\",target=/data/gdrive"

If I try to do the same with docker compose, however, it breaks:

# docker-compose.yml

services:
  myservice:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - type: bind
        source: "\"/run/user/1000/gvfs/google-drive:host=my_host,user=my.username/\""
        target: /data/gdrive

I get the error:

Error response from daemon: invalid volume specification: '/home/me/my_project/"/run/user/1000/gvfs/google-drive:host=my_host,user=my.username/":/data/gdrive:rw'

What confuses me even more is that it somehow prefixes the mount with the path to the project I'm working in...

I've also tried not escaping it and escaping it with source: | and source: >, but to no avail.

I have mounted my google drive folder in Ubuntu using gnome-online-accounts, which ends up being mounted like so:

/run/user/1000/gvfs/google-drive:host=my_host.com,user=my.username

Mounting this in a docker container works fine if I escape it correctly, i.e.:

--mount "type=bind,\"source=/run/user/1000/gvfs/google-drive:host=my_host.com,user=my.username/\",target=/data/gdrive"

If I try to do the same with docker compose, however, it breaks:

# docker-compose.yml

services:
  myservice:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - type: bind
        source: "\"/run/user/1000/gvfs/google-drive:host=my_host.com,user=my.username/\""
        target: /data/gdrive

I get the error:

Error response from daemon: invalid volume specification: '/home/me/my_project/"/run/user/1000/gvfs/google-drive:host=my_host.com,user=my.username/":/data/gdrive:rw'

What confuses me even more is that it somehow prefixes the mount with the path to the project I'm working in...

I've also tried not escaping it and escaping it with source: | and source: >, but to no avail.

Share Improve this question asked Feb 7 at 16:16 Samuel NeugberSamuel Neugber 1,1891 gold badge11 silver badges17 bronze badges 3
  • Does it work if you remove all of the quotes and backslashes in the source: value? I can see Compose getting confused by the path not starting exactly with a / character and then believing it's a relative path. – David Maze Commented Feb 7 at 16:27
  • No, unfortunately not: Error response from daemon: invalid volume specification: '/run/user/1000/gvfs/google-drive:host=my_host.com,user=my.user/:/data/gdrive:rw' – Samuel Neugber Commented Feb 7 at 17:36
  • The only way I've found to do this, is to create the volume ahead of time and mark it as external in the docker compose file: docker volume create \ --driver local \ -o o=bind \ -o type=none \ -o device=/var/app/data \ example-volume from here: til.hashrocket.com/posts/… – Samuel Neugber Commented Feb 7 at 19:34
Add a comment  | 

1 Answer 1

Reset to default 0

I've also asked in the docker forum, and it looks like you need to create a name volume to get this to work:

services:
my_service:
  ...
  volumes:
     - gdrive:/data/gdrive

volumes:
  gdrive:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: "/run/user/1000/gvfs/google-drive:host=my_host.com,user=my.username/"
发布评论

评论列表(0)

  1. 暂无评论