I want to mount the host vm in Docker for Windows in my container (for backup purpose). I found a short article about it which says to run
docker container run --rm -it -v /:/host alpine
to do this. I tried and it works fine. Now i wanted to put it into a docker-compose file. However
volumes: - / :/host:ro
doesn’t work. I don’t get an error message, the folder is just empty. The space in front of the colon was necessary, without it I got the error
invalid volume specification: '/host_mnt/host:ro'
I also tried using single and double quotes. But I don’t think that is the problem. I tried mounting /var instead / and got the same empty directory.
Does someone know how to set this up in docker-compose or is this a bug?