Home > Software engineering >  Error trying to set up volumes in Docker Compose file
Error trying to set up volumes in Docker Compose file

Time:09-14

I am trying to run a docker-compose file and am trying to add volumes to config folder shown below however I get the error message below. I am running Ubuntu-20.04 on Windows 10. I get the error from the part where I set the home directory under the volumes: section. Docker demands that I use absolute path to define volumes. The contents of the docker-compose file is shown below. How would I be able to fix this?

Error:

edge@D-O5F1K:/mnt/c/Users/Edge/Desktop/Docker-Linux-Containers$ docker compose up -d
[ ] Running 0/1
 ⠹ Container webtop  Creating                                              2.2s 
Error response from daemon: invalid volume specification: '/run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/Ubuntu-20.04/8c2793a7f76fcc2d6e6ac4f4109fe56011c82cba08a35e2d775e546876c17da8:config:rw': invalid mount config for type "bind": 
invalid mount path: 'config' mount path must be absolute

docker-compose file contents:

version: "2.1"
services:
  heimdall:
    image: ghcr.io/linuxserver/webtop:ubuntu-mate #choose a tag
    container_name: webtop
    #priviledged: true #optional but not needed unless you are running kde or i3 or other tools
    volumes:
      - /mnt/c/Users/Edge/Desktop/Docker-Linux-Containers/config:config #home directory
      #- /var/run/docker.sock:var/run/docker.sock #optional
    environment:
      - PUID=1000 #based on id
      - PGID=1000 #based on group
      - TZ=Canada/Toronto #your timezone
    ports:
      - 3000:3000
    shm_size: "3gb" #optional but set to 1gb or higher to prevent browser crashes 
    restart: unless-stopped #restart on error 

Tree:

.
├── README.md
├── config
└── docker-compose.yml

Command used to run container:

docker compose up -d

CodePudding user response:

Error is 'config' mount path must be absolute.

Replace config in /mnt/c/../config:config with absolute path of config in your container

e.g. /mnt/c/../config:/home/user/config

  • Related