I know this is an ancient post, but I was facing a similar error. I had command traefik error: stat /etc/traefik/traefik.yml: permission denied
, and am using Rocky Linux 9 with SELinux. The solution I found after a while is as follows (copied from an IRC chatroom)
Explaination of how it happened- This error occurs when SELinux is added to the docker daemon, enabling SELinux protections over docker containers. Typically this is done by creating the file/adding Line 1: { Line 2: "selinux-enable": true Line 3: }
to /etc/docker/daemon.json
Personally I did this for Mailcow, but it's also generally recommended if you're using an SELinux distro. It makes it so any file or directory without the label svirt_sandbox_file_t
can't be read or written to from docker containers, even when mounted, unless they're privledged (which is bad for your security.
SOLUTION-
sudo chcon -Rt svirt_sandbox_file_t $YOUR_CONTAINER_DIRECTORY (ex: /opt/appdata/traefik)
Only run that commend on a directory/file you KNOW you want to be able to access from docker, you don't want to give it access to something like "/" because then you negate the point of having SELinux.