portainer: Failed to mount file on new stack creation
Bug description
I’m getting the following error while trying to create new stack through portainer.
portainer_1 | time="2018-07-15T19:37:20Z" level=error msg="Failed Starting taskwarriorweb : Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused \"process_linux.go:402: container init caused \\\"rootfs_linux.go:58: mounting \\\\\\\"/data/compose/1/hosts\\\\\\\" to rootfs \\\\\\\"/var/lib/docker/overlay2/2068c67764c58a607d468debca1df30a8ec965124b12305a54097eb233feb7eb/merged\\\\\\\" at \\\\\\\"/var/lib/docker/overlay2/2068c67764c58a607d468debca1df30a8ec965124b12305a54097eb233feb7eb/merged/etc/hosts\\\\\\\" 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"
I’m using repository as a source for the new stack.
docker-compose.yml
version: "2"
services:
taskwarriorweb:
image: zebradil/taskwarrior-web
ports:
- 5678:5678
volumes:
- ./.taskrc:/root/.taskrc
- ./.task:/root/.task
- ./hosts:/etc/hosts
extra_hosts:
- task.host.com:138.200.200.100
All the files from the volumes section are located in the same directory with docker-compose.yml.
.taskrc and hosts are files, .task is a directory.
Technical details:
-
Portainer version: 1.18.1
-
Docker version (managed by Portainer): 18.05.0-ce
-
Platform (windows/linux): Linux / Centos 7
-
Command used to start Portainer (
docker run -p 9000:9000 portainer/portainer):docker-compose upwith the following config:version: '2' services: portainer: image: portainer/portainer command: -H unix:///var/run/docker.sock volumes: - /var/run/docker.sock:/var/run/docker.sock - portainer_data:/data ports: - 9000:9000 volumes: portainer_data:
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 20 (9 by maintainers)
Commits related to this issue
- fix(stacks): enforce-stack-permissions EE-3683 (#2046) * fix(stacks): enforce stack permissions EE-3683 — committed to portainer/portainer by testA113 2 years ago
It would be nice if relative paths would work.
Relative paths should work when creating a stack from a git repository.
Ok, we’ll investigate.
Portainer clones a repo inside the container, or if you are using a persistent volume it will be inside that. As such with the current implementation, relative paths don’t work.
For now you can reference the full path to the directory inside
/var/lib/docker/volumes/portainer_data/_data/compose/idbut you will have to find the id once the repo is cloned inside the portainer volume and edit the stack to reflect thisI’ve had the same problem deploying a stack from git. In my case there was no error message, it just didn’t work.
In the end I SSH-ed onto the machine (single instance as well) and found the absolute path to the checked out files. After editing the stack in Portainer’s editor to reference the files via absolute paths (
/var/lib/docker/volumes/portainer_data/_data/compose/7/...) it started working.I made a clean example, and the error appeared again. Here is the the repo: https://github.com/Zebradil/portainer-test
In the root directory of the repo:
docker-compose.ymlhoststestdir/testfiledocker-compose.yml
And here are portainer logs for a stack creation:
@Zebradil btw. I just noticed that you are using compose stack instead of swarm stack. There is no config option available. You need enable Swarm mode to get that feature to use.
Problem with relative mounts is that source files/folders does not exist on folder where process are actually run and at least I don’t even know which folder they should be created.
Problem is on these relative paths which you are trying to use.
You have two options:
and modify stack file to use bind mount using absolute paths like this:
and modify your container image to look these files from /data folder.