Issues with running traefik inside portainer

Hello all!
I've recently moved to traefik from nginx, and I would like to run it inside a Docker container, using portainer.
Now, I have a basic setup done, and yet, the container always crashes with the error:

ERR Command error | error=command traefik error: read /etc/traefik/traefik.yml: is a directory

When I run it with normal docker on the same machine, it works just fine.
My configs are as follows:
docker-compose.yml:

---
services:
  traefik:
    image: "traefik:v3.4"
    container_name: "traefik"
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik.yml:/etc/traefik/traefik.yml:ro
    networks:
      - traefik
    restart: unless-stopped
networks:
  traefik:
    external: true

traefik.yml:

global:
  checkNewVersion: true
  sendAnonymousUsage: false
log:
  level: DEBUG
api:
  dashboard: true
  insecure: true
entryPoints:
  web:
    address: ":80"
  websecure:
    address: ":443"
    asDefault: true

Before you ask, the docker compose file and the traefik static config file are both in the same directory, not in any subdirectories, I am certain the path is correct.

I'm looking forward to any help on the matter!

If Docker doesn’t find a local bind mount, it creates a directory AFAIK.

So I would think you got the right compose file, but the execution of compose by Portainer happens in a different directory, so the relative path to config file does not work. Maybe try with an absolute path.

Using an absolute path is not ideal as it's hosted on git.
Even so, I use the web repo option on portainer, so all the files that it needs get pulled down from github (The entire repository) and used there.

You could try to add the absolute location to your Traefik compose and place the config file in root (which will always exist):

command: 
  - --configFile=/traefik.yml