Docker compose bind mount with colon & comma in path not working

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:

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

and escaping it with source: | and source: >:

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

but to no avail…

Have your tries quoting the whole path with single quotes?

I remember we had a topic with a length discussion about paths with colons, it think it was about drive serial numbers. You could check the forum search.

Worst case: create a bind on the folder (something like this: mount --bind '/run/user/1000/gvfs/google-drive:host=my_host.com,user=my.username/' /mnt/gdrive) and then bind /mnt/grdive into the container.

Yes, I’ve tried quoting about every way I could think of. Unless I’ve missed the one option it doesn’t seem to work.

Worst case: create a bind on the folder […]

That’s pretty much what I’ve settled on in the meantime, I first create a dedicated volume:

docker volume create \
  --driver local \
  -o o=bind \
  -o type=none \
  -o device="/run/user/1000/gvfs/google-drive:host=my_host.com,user=my.username/" \
  gdrive

Then in the docker compose I bind it as normal:

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

volumes:
  gdrive:
    external: true

Bit annoying, but at least it’s workable for now…

Your solution is better than what I have proposed :slight_smile:

You could create the named volume backed by a bind in the compose file as well:

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

Just keep in mind that volume are immutable, so that updates on the compose file will not be reflected back to the configuration of the volume, unless it’s manually removed.

Oh nice, thanks! I’ve used docker for years, but never had to get into that much detail on volumes… TIL :smiley: