dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

Traefik never start: Error: read /etc/traefik/traefik.yml: is a directory

Open LukaLiuzzi opened this issue 1 year ago • 18 comments

To Reproduce

Download Dokploy from official method (curl -sSL https://dokploy.com/install.sh | sh) Run sudo docker ps -a Run sudo docker logs dokploy-traefik

Current vs. Expected behavior

Due to the bug, traefik never starts and the container keeps restarting in a loop.

Provide environment information

Raspberry Pi 3
Linux raspberrypi 6.12.25+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.25-1+rpt1 (2025-04-30) aarch64 GNU/Linux
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian

Dokploy version: 0.22.7

Which area(s) are affected? (Select all that apply)

Installation, Traefik, Docker

Are you deploying the applications where Dokploy is installed or on a remote server?

Same server where Dokploy is installed

Additional context

The problem is in the /etc/dokploy/traefik/traefik.yml path. traefik.yml is being interpreted as a directory, not a file. I tried stopping the dokploy-traefik container, delete the directory and create the traefik.yml file, but when starting the container again I get this error: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/etc/dokploy/traefik/traefik.yml" to rootfs at "/etc/traefik/traefik.yml": mount src=/etc/dokploy/traefik/traefik.yml, dst=/etc/traefik/traefik.yml, dstFd=/proc/thread-self/fd/8, 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 Error: failed to start containers: 45621969a19e

Will you send a PR to fix it?

No

LukaLiuzzi avatar Jun 09 '25 05:06 LukaLiuzzi

Possibly related to https://github.com/Dokploy/dokploy/issues/1586?

nikodunk avatar Jun 15 '25 23:06 nikodunk

Yes, it seems to be the same issue as #1586,

can you run this command?

ls -l /etc/dokploy/traefik and share the output.

can you try this?

  1. rm -rf /etc/dokploy/traefik/traefik.yml This deletes the folder
  2. docker service scale dokploy=0
  3. docker service scale dokploy=1

then run ls -l /etc/dokploy/traefik again

Siumauricio avatar Jun 22 '25 01:06 Siumauricio

not OP, but for me on CoreOS where I can consistently reproduce it. (On coreOS Etc is writeable, but the rest of the file system is not. So that may be it but maybe this will still give a clue?).

ls -l /etc/dokploy/traefik
drwxr-xr-x. 2 root root 6 Jun 22 16:03 dynamic
drwxr-xr-x. 2 root root 6 Jun 22 16:03 traefik.yml
rm -rf /etc/dokploy/traefik/traefik.yml
$ docker service scale dokploy=0
dokploy scaled to 0
overall progress: 0 out of 0 tasks 
verify: Service dokploy converged 

$ docker service scale dokploy=1
dokploy scaled to 1
overall progress: 1 out of 1 tasks 
1/1: running   [==================================================>] 
verify: Service dokploy converged 
$ ls -l /etc/dokploy/traefik
total 0
drwxr-xr-x. 2 root root 6 Jun 22 16:03 dynamic
drwxr-xr-x. 2 root root 6 Jun 22 16:08 traefik.yml
cd /etc/dokploy/traefik/
cat traefik.yml

$ cat traefik.yml
cat: traefik.yml: Is a directory

All of above commands run as root, after the initial curl -sSL https://dokploy.com/install.sh | sh yields This script must be run as root

nikodunk avatar Jun 22 '25 16:06 nikodunk

I had the same problem after a fresh install on Ubuntu 24.04 (using a Scaleway Dedibox). I encountered the same as in #1587, checked the Traefik logs and it showed the same message as in this post.

@Siumauricio gave some pointers on how to resolve this in https://github.com/Dokploy/dokploy/issues/2018#issuecomment-2993859579. However, if only dokploy is restarted, traefik.yml will be recreated as a directory.

What I did:

docker service scale dokploy=0
rm -rf /etc/dokploy/traefik/traefik.yml
docker stop dokploy-traefik
docker service scale dokploy=1

After a while, this will create the file traefik.yml. At this point, dokploy-traefik will not restart because it is attached to a directory and expecting that when starting again. So I recreated the dokploy-traefik container with the installation script:

docker rm dokploy-traefik
docker run -d \
        --name dokploy-traefik \
        --network dokploy-network \
        --restart always \
        -v /etc/dokploy/traefik/traefik.yml:/etc/traefik/traefik.yml \
        -v /etc/dokploy/traefik/dynamic:/etc/dokploy/traefik/dynamic \
        -v /var/run/docker.sock:/var/run/docker.sock \
        -p 80:80/tcp \
        -p 443:443/tcp \
        -p 443:443/udp \
        traefik:v3.1.2

Now the file is successfully created, traefik runs and the domain settings can be applied. I don’t have enough experience or knowledge to provide a permanent fix for this, but I hope this helps debugging the issue.

rvanderveen avatar Jun 29 '25 13:06 rvanderveen

Thanks for the solution, it is strange that nodejs tries to create a directory over the file, it is this function that creates the directory and the file.

https://github.com/Dokploy/dokploy/blob/5c73ced500dd4149a01a0a25a1026866cd800b23/packages/server/src/setup/traefik-setup.ts#L313-L328

I see it happens in some distros

Siumauricio avatar Jul 05 '25 20:07 Siumauricio

is there a fix coming up for this?

Physium avatar Jul 31 '25 04:07 Physium

Issue is still a problem

xandertreat avatar Aug 02 '25 05:08 xandertreat

I've experienced same issue, rvanderveen's fix solved it

emsitkowski avatar Aug 05 '25 10:08 emsitkowski

Issue is still a problem in v0.24.12

gohopo avatar Aug 21 '25 06:08 gohopo

what works for me was to use the recommend OS versions. hope this helps!

Physium avatar Aug 21 '25 10:08 Physium

Same issue with last version on date

herbalizer404 avatar Sep 06 '25 01:09 herbalizer404

Is this not a major issue or is it only a problem on some systems? It prevents me from accessing my dokploy instances and all services since I cannot make any routing.

MathiasBuus avatar Sep 17 '25 09:09 MathiasBuus

same issue with Ubuntu 22.04.5 LTS tried @rvanderveen fix on mine, didn't work, still has traefik.yml/ on etc/dokploy/traefik/traefik.yml/.

Edit: fixed it by stopping the traefik container first before removing

docker service scale dokploy=0
docker stop dokploy-traefik 
rm -rf /etc/dokploy/traefik/traefik.yml
docker service scale dokploy=1

PandesalPanpan avatar Sep 19 '25 06:09 PandesalPanpan

This issue should be fixed, feel free to reopen!

Siumauricio avatar Oct 05 '25 03:10 Siumauricio

I faced this issue on 0.25.6. didn't have time to investigate the root cause but found a quick workaround

  • make sure dokply-traefik container is stopped
  • remove /etc/dokploy/traefik/traefik.yml if it is a dir
  • Create the file and add the default content (I got it from another installation)
  • run the install script again

pavithmadusara avatar Oct 28 '25 06:10 pavithmadusara

It's just ridiculous! After a year, this problem still persists. Even on the fresh new Ubuntu Server 24.04 LTS 64bit system, I still encounter this error. I have reinstalled the system several times, but the problem remains the same. I'll just use Coolify instead.

Image

cyamoyed avatar May 11 '26 14:05 cyamoyed

hhhhhh, After I manually deleted the directory and created a new file, it prevented me from running the program. Moreover, it even expected the yml file to be a directory. I spent the whole night to run this shit project. FUCK!

Image

cyamoyed avatar May 11 '26 15:05 cyamoyed

once a containers bind mounts are set, you would need to recreate the container in order to change it.

initially the file didn't exist, so docker creates a directory, this breaks traefik, you fixed it externally, but restarting the container won't work as it now expects a directory mount

after removing the directory you also need to remove the container and recreate

the issue, is there is a small delay between starting dokploy and traefik, but if thats not enough and traefik starts before dokploy has created the file, it breaks traefik, instead on first run, the file at /etc/dokploy/traefik/traefik.yml should be created if it doesn't exist or dokploy should just mount the directory etc/dokploy/traefik/ and not the file. Also --mount should be used over -v since as per docs, as it allows more options including not creating directories if the file doesn't exist

djsisson avatar May 11 '26 15:05 djsisson