Docker Community Forums

Share and learn in the Docker community.

Docker-machine and volume mount


(Aeris22) #1

Hello here!

I use docker-machine for a development environment, because docker currently supports only iptables and so messes up my nftables based dev machine.

But I have a lot of troubles with volume mount on docker-machine.
For example, if I use a volume inside a docker-compose, nothing works at the end.

  traefik:
    image: traefik:1.5-alpine
    command: --api --traefiklog --debug
    volumes:
      - ./traefik:/etc/traefik/

In VM, an empty folder replicates the full path of the directory executing the docker-compose up command
And in container, ends up with an empty /etc/traefik folder

$ ls -al traefik 
-rw-r--r-- 1 aeris aeris  749 16 avril 09:33 localhost.crt
-rw------- 1 aeris aeris  227 16 avril 09:32 localhost.pem
-rw-r--r-- 1 aeris aeris  665 13 avril 20:04 traefik.toml

$ docker-machine ssh docker ls -al /home/aeris/foo/bar/baz/quz/traefik
total 0
drwxr-xr-x    2 root     root            40 May 15 13:37 .
drwxr-xr-x    3 root     root            60 May 15 13:37 ..

$ docker-compose exec traefik ls -al /etc/traefik
total 4
drwxr-xr-x    2 root     root            40 May 15 13:37 .
drwxr-xr-x   20 root     root          4096 May 15 13:37 ..

Same trouble for a file volume mount instead of a directory volume mount

  traefik:
    image: traefik:1.5-alpine
    command: --api --traefiklog --debug
    volumes:
      - ./traefik/traefik.toml:/etc/traefik/traefik.toml

Ends up with an empty directory at the expected file place

$ docker-compose exec traefik ls -al /etc/traefik/traefik.toml
total 4
drwxr-xr-x    2 root     root            40 May 15 13:59 .
drwxr-xr-x    3 root     root          4096 May 15 14:00 ..

$ docker-machine ssh docker ls -al /home/aeris/foo/bar/baz/quz/traefik/traefik.toml                                                                                             
total 0
drwxr-xr-x    2 root     root            40 May 15 13:59 .
drwxr-xr-x    4 root     root            80 May 15 13:59 ..

I try to rsync local pwd in place of the empty replicated hierarchy on the VM, but this is quite difficult because of permission (owned by root:root by default, not directly available through docker-machine ssh) and because docker-machine/docker-compose reset the replicated hierarchy or fails if already populate.

Seems something exists in docker-machine to handle volume mount (replication of local pwd volume source inside the VM), but doesn’t work in practice.
So, is there any way to (transparently or not) use volume mount with docker-machine?

It seems there is the same problems on Windows and Linux container (1 extra VM layer between physical machine and container, breaking volume mount)