dockerdocker-composedocker-volume

Docker compose bind mount with colon and comma in path


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.


Solution

  • 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/"