skip to Main Content

I have docker-compose.yml

volumes:
      - D:/Docker/config:/config
      - D:/Downloads:/downloads  

I can do this with docker-compose up without any issue

But in portainer stack, I got an error

Deployment error
failed to deploy a stack: Named volume "D:/Docker/config:/config" is used in service "test" but no declaration was found in the volumes section. : exit status 1  

Basically I want to map my host folder D:/Docker/config. How do I do this in portainer?

3

Answers


  1. Chosen as BEST ANSWER

    use /d/Downloads to make it work, thanks to @xerx593


  2. I spent a long time figuring this out

    So in Docker-Compose, on Windows running Docker Desktop in WSL2 mode when entering a mount point for a Bind Mount you have to format it

    - /mnt/DRIVE-LETTER/directory/to/location:/container/path
    

    An example would be

    - /mnt/k/docker/tv/xteve/config:/home/xteve/config
    

    You also have the option of using relative paths from where the Compose file is located but with Portainer that isn’t an option. I know, I tried everything I could think of. Then I was looking at tutorials & I saw the same thing @warheat1990 posted here & experimented with that.

    Portainer tells you to paste your Docker-Compose, but the paths are different. The paths inside Portainer will not work & be ignored or placed somewhere you can’t get to them from windows, unless you remove the "/mnt" & start with the drive letter

    - /DRIVE-LETTER/directory/to/location:/container/path
    

    An example would be

    - /k/docker/tv/xteve/config:/home/xteve/config
    

    I tested it & outside of Portainer without the "/mnt" it fails, but within Portainer it can’t be there. So far I’m fairly confident that there is no way to do it that works for both. Which is super annoying because Portainer makes it easy to paste your Compose or actually import the file, but then you must edit it, just nobody tells you that…

    Hope that helps

    Login or Signup to reply.
  3. edit : came here about the same question, and forgot the question was for portainer. This answer below worked in docker compose in windows.

    Not sure how helpful that is but as I was trying to deploy Filerun in docker desktop windows, I ran into that issue myself.

    Goal was to have my containers data in one place on a windows folder but Filerun files were a different drive.

    I fumbled A LOT but what worked for me in the end with docker compose :

    volumes:
      - D:myfolder:/mnt/myfolder
      - ./filerun/html:/var/www/html
      - ./filerun/user-files:/user-files # (default, could be pointed directly to mnt)
    

    The ./filerun define a relative path to where the docker compose yml is stored and executed so that I have persistence in my windows folder there even when removing a compose (this is not intended for intensive prodiction stuff).

    And my files were accessible in Filerun through /mnt/myfolder.

    Not sure if docker desktop has been updated on that since the previous answer was given.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search