Can't mount directory/file

I am trying to deploy the following stack in portainer

---
version: "3.8"
services:
  dashy:
    # To build from source, replace 'image: lissy93/dashy' with 'build: .'
    # build: .
    image: lissy93/dashy
    container_name: Dashy
    # Pass in your config file below, by specifying the path on your host machine
    volumes:
      - ~/dashy/my-conf.yml:/app/public/conf.yml
    ports:
      - 4000:80
    # Set any environmental variables
    environment:
      - NODE_ENV=production
    # Specify your user ID and group ID. You can find this by running `id -u` and `id -g`
    #  - UID=1000
    #  - GID=1000
    # Specify restart policy
    restart: unless-stopped
    # Configure healthchecks
    healthcheck:
      test: ['CMD', 'node', '/app/services/healthcheck']
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 40s

But I get the following error

failed to deploy a stack: Network my_dashy_default 
Creating Network my_dashy_default 
Created Container Dashy 
Creating Container Dashy 
Created Container Dashy 
Starting Error response from daemon: 
failed to create shim task: 
OCI runtime create failed: 
runc create failed: 
unable to start container process: 
error during container init: 
error mounting "/dashy/my-conf.yml" to rootfs at "/app/public/conf.yml": 
mount /dashy/my-conf.yml:/app/public/conf.yml (via /proc/self/fd/6), flags: 0x5000: 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

~/dashy/my-conf.yml does exist

I don’t begin to understand how this all works but if I change the volumes part as follows (incorrect conf file name on host), the instance starts, It’s obviously not correct but dashy starts up.

volumes:
      - ~/dashy/my-conf.yml:/app/public/onf.yml

Format your original code for better readability with 3 backticks in front and after, or select the code and press </>. In yaml every space matters.

Try using an absolute path, without ~.

You changed the filename in the container, not on the host. That’s why it worked. The left side is the path on the host and the right side is the path in the container.

The error message mentiones:

error mounting "/dashy/my-conf.yml"

without the tilde character at the beginning which indicates that user’s home is the system root. Unless you removed the original home from the error message. Maybe you are trying to run Docker with a different user so the file does exist ibut not where Docker is looking for it. When compose try to mount a nonexistent file it will create it as a folder and mounts that. At least when you use the short syntax not the long syntax. So you tried to mount a folder onto a file exactly as the error message says. Then you changed the path in the container so you mounted a folder in the container at a location where no file or folder existed so it worked.

PS: I formatted your post, but please, follow @bluepuma77’s instructions next time and format your post properly. More help: How to format your forum posts

Apologies re the formatting

---
version: "3.8"
services:
  dashy:
    # To build from source, replace 'image: lissy93/dashy' with 'build: .'
    # build: .
    image: lissy93/dashy
    container_name: Dashy
    # Pass in your config file below, by specifying the path on your host machine
    volumes:
      - ~/dashy/my-conf.yml:/app/public/onf.yml
    ports:
      - 4000:80
    # Set any environmental variables
    environment:
      - NODE_ENV=production
    # Specify your user ID and group ID. You can find this by running `id -u` and `id -g`
    #  - UID=1000
    #  - GID=1000
    # Specify restart policy
    restart: unless-stopped
    # Configure healthchecks
    healthcheck:
      test: ['CMD', 'node', '/app/services/healthcheck']
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 40s

Regarding the my-conf.yml file I tried with the file, without the file; basically many different permutations and none worked.

I have another on the same machine and using the tidel works although this time it is mapping a folder to a folder.

version: "2"
services:
  remotely:
    image: immybot/remotely:latest
    ports:
      - 5000:5000
    volumes:
      - ~/remotely/var/www:/remotely-data
    restart: unless-stopped

I have check and ~/remotely/var/www has the same permissions and ownership as ~/dashy so if Docker can see one it should see the other too. Unless in that case even though it runs, maybe the mapping is not working; not sure.

Having said all that @rimelek your explanation makes sense i.e. Docker cannot see the file that I am referring to. I will sleep on things and take another look tomorrow.

Thanks again.

Without what the content of those host folders is I can’t be sure you see the folder that is mounted to the container or just a folder witha the same name somewhere else. The only way to makes ure you see the right folder is to write something to that folder on the host and check it in the container to see if it is there. Or create a new file in the container and see if it eppears on the host.

Thanks @rimelek for your direction. This helped me work it out.

For completion I will go through my steps.

I decided to start from the beginning, using the docker command line.

I created an instance without a mapping so that I could see what is in conf.yml by default.

sudo docker run -d \
  -p 4000:80 \
  --name my-dashboard \
  --restart=unless-stopped \
  lissy93/dashy:latest

I then did the following and could see that config.yml existed in the containter.

sysadmin@services:~$ sudo docker exec -it my-dashboard sh
/app # ls /app/public/
conf.yml favicon.ico fonts img index.html initialization.html item-icons loading-screen.css manifest.json robots.txt web-icons widget-resources

I then created my config file in ~/dashy/my-config.yml

sysadmin@services:~/dashy$ sudo nano my-conf.yml
sysadmin@services:~/dashy$ ls
my-conf.yml

I then ran the below and it all worked

sysadmin@services:~/dashy$ sudo docker run -d \
  -p 4000:80 \
  -v ~/dashy/my-conf.yml:/app/public/conf.yml \
  --name my-dashboard \
  --restart=unless-stopped \
  lissy93/dashy:latest

There must have been a permission issue on my original file.

Thanks again

Suddenly Dashy stopped working. I tried recreating and it returned to the same issue above. Googling seems to indicate that a number of people have this issue.

I think I will move onto another Dashboard but thanks for assisting thus far.