2

Docker-compose.yml works well on a mac machine but our developers use both mac and windows computers (windows cannot use hyper-v due to other virtual box requirements.

It is possible to share a folder through VM interface by global path /volume_data_dir

This however causes issues between the environments as mac and production uses relative path ./volume_data_dir as mount point.

I've also tried mounting the folder as /home/docker/volume_data_dir (/home/docker being the home folder of docker inside virtualbox) but no cake.

Thus my question is: what is the directory to share volumes for docker-compose, running inside vmware, to be able to mount the folders using relative path ./volume_data_dir?

the docker-compose.yml in question:

version: '3'
services:
django:
  container_name: server
  restart: always
  depends_on:
    - db
  build:
    context: .
    dockerfile: dockerfile
  image: server
  stdin_open: true
  tty: true
  volumes:
    - ./data:/var/www/data
  ports:
    - "8000:8000"

I've read a very comprehensive answer by GreensterRox ( https://stackoverflow.com/a/48442262/3986395), but unfortunately, it didnt help

Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35

2 Answers2

1

A sort of hacky approach that I managed to come up with, was to use the env variables, defined in the docker envfile, to pass the mount path:

version: '3'
services:
    django:
      container_name: server
      restart: always
      depends_on:
         - db
    build:
        context: .
        dockerfile: dockerfile
    image: server
    stdin_open: true
    tty: true
    volumes:
        - $VOLUME_MOUNT_PATH:/var/www/data
    ports:
        - "8000:8000"

If anyone has any better solutions, let me know!

Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35
1

One of the possible solution is:

  1. We have to configure Oracle VirtualBox to have access to Your folder: go to Settings, Shared Folders, add Your folder "data" to the list.

  2. In .yml code we have to use "//" before Your folder:

    volumes:  
        - //p_data:/var/www/data

where "p_data" is the pseudonym of Your initial folder "data", defined in VirtualBox Shared Folders menu.

This solution is taken from article of Charles Stover: https://medium.com/@Charles_Stover/fixing-volumes-in-docker-toolbox-4ad5ace0e572

Bhramari
  • 11
  • 2
  • This was my initial solution as well. Problem with it arises if your team uses mixed-os equipment. Adding env var bypasses this limitation as every device can reconfigure the left side of the mapping on their own without committing a set of different docker-compose-.yml's – Simas Joneliunas Jul 14 '20 at 12:43