Docker Community Forums

Share and learn in the Docker community.

Docker - Set directory path on a environment variable in Windows

I have a .env file containing some environment variables. One of them refers to a directory path each user has to specify to make the system work. When I tried it in a Linux host it worked perfectly, but now trying it in Windows 10 system I am having some troubles.

In Linux the ENV looked like this:

DATA_DIRECTORY_PATH=/home/user/absolute/path/to/folder/data/

I tried to just copy the Windows folder path the same way:

DATA_DIRECTORY_PATH=C:\Users\luisc\Luiscri\4Teleco\TFG\TwitterCluster\Proyectos\MABSED\data

However this attempt showed and error saying Error on mounting volume - Directory or file not found

After Googling how the path should be declared in Windows I tried this way:

DATA_DIRECTORY_PATH=//c/Users/luisc/Luiscri/4Teleco/TFG/TwitterCluster/Proyectos/MABSED/data/

And now the error looks like this:

ERROR: for orchestrator  Cannot start service orchestrator: b'OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \\"rootfs_linux.go:58: mounting \\\\\\"/etc/localtime\\\\\\" to rootfs \\\\\\"/var/lib/docker/overlay2/3e21d16a9b19cf553cebccab2454327590e8024abe3643c5577f04f168660488/merged\\\\\\" at \\\\\\"/var/lib/docker/overlay2/3e21d16a9b19cf553cebccab2454327590e8024abe3643c5577f04f168660488/merged/usr/share/zoneinfo/UCT\\\\\\" caused \\\\\\"not a directory\\\\\\"\\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type'

How is the correct way to declare a path in an environment variable in Windows? I come from Linux and I am pretty new to developping on Windows.

Just in case it is needed, here is my docker-compose.yml:

version: '2'

services:
  dashboard:
    build: demo-dashboard/
    ports:
      - "8080:8080"
    environment:
      - ES_ENDPOINT_EXTERNAL=${ES_ENDPOINT_EXTERNAL}
      - http.cors.enabled=true
      - http.cors.allow-origin=${ES_ENDPOINT_EXTERNAL}
      - http.cors.allow-headers=Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With
      - http.cors.allow-credentials=true
    volumes:
      - ./demo-dashboard:/usr/src/app
    networks:
      - dashboard-network

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.7.0
    environment:
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - http.cors.enabled=true
      - http.cors.allow-origin=http://localhost:8080
      - http.cors.allow-headers=Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With
      - http.cors.allow-credentials=true
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    mem_limit: 1g
    cap_add:
      - IPC_LOCK
    volumes:
      - esdata1:/usr/share/elasticsearch/data/
    networks:
      - dashboard-network
    ports:
      - 9200:9200

  orchestrator:
    image: orchestrator-mabsed
    build: orchestrator/
    environment:
      ES_HOST: 'elasticsearch'
    tty: true
    volumes:
      - socialdata1:/usr/src/data/
      - "/etc/localtime:/etc/localtime:ro"
    networks:
      - dashboard-network

  streamer:
    image: streamer-mabsed
    build: streamer/
    tty: true
    volumes:
      - socialdata1:/usr/src/data/

volumes:
  esdata1:
    driver: local

  socialdata1:
    driver: local
    driver_opts:
      type: none
      device: ${DATA_DIRECTORY_PATH}
      o: bind

networks:
  dashboard-network:
    driver: bridge