1

I'm trying to take a config file and replace the already existing default.conf in nginx.

My super simple Docker compose:

version: '3.3'
services:
  qwc-api-gateway:
    image: nginx:1.19
    volumes:
      - ./default.conf:/etc/nginx/conf.d/default.conf

For convenience, I even published the two files here: https://github.com/Xentraxx/qwc-docker

The problem: If I try to build a stack from this repository in portainer, it fails with the error message:

Error response from daemon: 
failed to create shim: 
OCI runtime create failed: 
runc create failed: 
unable to start container process:
error during container init: 
error mounting "/data/compose/7/default.conf" to rootfs at "/etc/nginx/conf.d/default.conf": 
mount /data/compose/7/default.conf:/etc/nginx/conf.d/default.conf (via /proc/self/fd/6), 
flags: 0x5001: 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

If I run docker-compose up -d locally, the container starts and I can see in the logs that the default.conf has my desired values.

I couldn't find anything helpful for this online, only people saying that the source file probably doesn't exist. So feel free to take my repository, try to create a stack from it in Portainer and let me know what I am doing wrong. Because I have no idea anymore.

Also please ignore that the container crashes after it started. This is not related.

Xentrax
  • 81
  • 3
  • 9
  • `ls -l /data/compose/7/default.conf`? (Because that is what docker is trying to mount into the container) – Tomáš Pospíšek Nov 24 '22 at 06:18
  • @TomášPospíšek `/data/compose/7/` is from my understanding the path of the volume which is created during the docker compose and from where the file is supposed to be copied to the new location. So the default.conf is laying in the root directory as expected. I can't ls into the container unfortunately, because it doesn't build. – Xentrax Nov 24 '22 at 15:05
  • Did you have a look at https://stackoverflow.com/questions/45972812/are-you-trying-to-mount-a-directory-onto-a-file-or-vice-versa ? – Tomáš Pospíšek Nov 25 '22 at 11:47
  • @TomášPospíšek Yes I tried everything. Docker is on the newest version, I tried static paths, relative paths, binds, in quotes, single quotes, I checked if the default.conf is UTF-8 and more. – Xentrax Nov 25 '22 at 22:53
  • So you are doing all that on Windows (could you then please add that info above to your question?)? – Tomáš Pospíšek Nov 27 '22 at 16:46
  • And you did do [this](https://stackoverflow.com/a/45973133/4640820)? – Tomáš Pospíšek Nov 27 '22 at 16:47
  • and from the same directory, from where you execute docker-compose, doing `cat ./default.conf` will output the contents of the file? What does `ls -ld /data/ /data/compose/; ls -l /data/compose ./default.conf` output? – Tomáš Pospíšek Nov 27 '22 at 16:54
  • @Xentrax. Did you find a solution? I have exactly the same problem. – lorenzo Dec 30 '22 at 15:13
  • @lorenzo No unfortunately not. I have given up. If you find any solution please let me know. – Xentrax Feb 10 '23 at 13:49

1 Answers1

0

I had the same problem with gitlab-runner. I use dind, and solution is to share folder which will be mount between containers: between gitlab-runner and docker-with-socket containers:

at /etc/gitlab-runner/config.toml

...
volumes = ["/cache","/opt"]
...

In your case with error

error mounting "/data/compose/7/default.conf"

you should share /data folder.

helvete
  • 2,455
  • 13
  • 33
  • 37
pycek
  • 1
  • 1