Change volume path in docker-compose depending on operating system (windows or macOS)

Viewed 160

Would anyone know why the volume path below doesn't work for Windows but for macOS and Linux?

docker-compose.yml file that works with macOS and Linux

version: "3"
services:
  mongo:
    image: "mongo:latest"
    ports:
      - "27017:27017"
    volumes:
      - ./api/db:/data/db

docker-compose.yml file that works with Windows

version: "3"
services:
  mongo:
    image: "mongo:latest"
    ports:
      - "27017:27017"
    volumes:
      - .\api\db:\data\db

Is there anyway of combining these files together so they works on both operating systems?

0 Answers
Related