# Adding a docker provider to traefik k3s error docker.sock access

**URL:** <https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303>\
**Category:** Traefik v2\
**Tags:** kubernetes-ingress, docker\
**Created:** [April 18, 2023, 9:45am UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303 "2023-04-18T09:45:58Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![PahaCore](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/pahacore/32/6998_2.png) [@PahaCore](https://community.traefik.io/u/PahaCore)\
**Post date:** [April 18, 2023, 9:45am UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303/1 "2023-04-18T09:45:58Z")

</div>

k3s version v1.26.3+k3s1  
Docker version 23.0.3  
Traefik 2.9.4

default installation with traefik

```auto
curl -sfL https://get.k3s.io | sh -

```

Check for Ready node, takes ~30 seconds

```auto
sudo k3s kubectl get node

```

adding configuration according to k3s instructions and traefik commands

```auto
https://docs.k3s.io/helm
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
name: traefik
namespace: kube-system
spec:
valuesContent: |-
additionalArguments:

--accesslog=true
--global.checknewversion
--providers.docker=true
--providers.docker.exposedByDefault=false
--entrypoints.web.http.redirections.entryPoint.to=:443
--entrypoints.web.http.redirections.entryPoint.scheme=https

```

I also used such a command , the result is the same

```auto
--providers.docker.endpoint=unix:///var/run/docker.sock

```

```auto
level=error msg="Provider connection error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?, retrying in 1.642087069s" providerName=docker

```

the user is a member of the docker group and executes docker commands , just like root

What did you see instead?  
Provider connection error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

What version of Traefik are you using?  
Traefik 2.9.4

What is your environment & configuration?

```auto
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
name: traefik
namespace: kube-system
spec:
valuesContent: |-
additionalArguments:
- --accesslog=true
- --global.checknewversion
- --providers.docker=true
- --providers.docker.exposedByDefault=false
- --entrypoints.web.http.redirections.entryPoint.to=:443
- --entrypoints.web.http.redirections.entryPoint.scheme=https

```

If applicable, please paste the log output in DEBUG level

```auto
level=error msg="Provider connection error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?, retrying in 1.642087069s" providerName=docker

```

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [April 18, 2023, 2:29pm UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303/2 "2023-04-18T14:29:27Z")

</div>

We don’t use k3s, so I have no idea how to do it right. But why do want to use `provider.docker` for Traefik Docker Configuration Discovery in a kubernetes setup? Usually this is used for pure Docker (Swarm) environments.

---

<div class="post-metadata">

**Author:** ![PahaCore](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/pahacore/32/6998_2.png) [@PahaCore](https://community.traefik.io/u/PahaCore)\
**Post date:** [April 18, 2023, 2:49pm UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303/3 "2023-04-18T14:49:52Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/7/7caa1441fb4d8199728876e6b1bc3857fe5f7464.png)

because it can , I used k3s kubernetes and wanted to connect docker provider to access the internet

k3s uses traefik by default

---

<div class="post-metadata">

**Author:** ![PahaCore](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/pahacore/32/6998_2.png) [@PahaCore](https://community.traefik.io/u/PahaCore)\
**Post date:** [April 18, 2023, 2:52pm UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303/4 "2023-04-18T14:52:32Z")

</div>

this is what my panel looks like now

 ![image](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/c/c23fdc15e9a1b722a1396410cb00861c9410f581.png)

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [April 18, 2023, 4:15pm UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303/5 "2023-04-18T16:15:51Z")

</div>

I think I have never seen a `provider.docker` used in any k8s related community post here.

Did you check the docs?

"[A Simple Use Case of Traefik Proxy and Kubernetes](https://doc.traefik.io/traefik/getting-started/quick-start-with-kubernetes/)"  
"[Install Traefik - Use the Helm Chart](https://doc.traefik.io/traefik/getting-started/install-traefik/#use-the-helm-chart)"  
"[Install And Configure Traefik Proxy with Helm](https://traefik.io/blog/install-and-configure-traefik-with-helm/)"

---

<div class="post-metadata">

**Author:** ![PahaCore](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/pahacore/32/6998_2.png) [@PahaCore](https://community.traefik.io/u/PahaCore)\
**Post date:** [April 18, 2023, 4:41pm UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303/6 "2023-04-18T16:41:06Z")

</div>

traefik can work with different providers - this is understandable, what is listed is the usual easy initial instructions - in fact, it is not clear why traefik does not have access to the docker socket

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [April 19, 2023, 5:48am UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303/7 "2023-04-19T05:48:10Z")

</div>

When running Traefik in Docker, you have to mount `unix:///var/run/docker.sock` into the Traefik container to be read by `provider.docker`.

I assume you need to do the same when running in k3s.

---

<div class="post-metadata">

**Author:** ![PahaCore](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/pahacore/32/6998_2.png) [@PahaCore](https://community.traefik.io/u/PahaCore)\
**Post date:** [April 19, 2023, 6:32am UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303/8 "2023-04-19T06:32:06Z")

</div>

> [@PahaCore](#):
>
> I also used such a command , the result is the same
> 
> ```auto
> --providers.docker.endpoint=unix:///var/run/docker.sock
> 
> ```

----providers.docker=true is the same - by default as --providers.docker.endpoint=unix:///var/run/docker.sock

> **[Traefik Docker Documentation - Traefik](https://doc.traefik.io/traefik/providers/docker/)**
>
> Learn how to achieve configuration discovery in Traefik through Docker. Read the technical documentation.

how would I find out if it is true that traefik can use all these providers at the same time or is it just a picture

 ![image](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/4/4dc02c704ee3a39665454de1173666169e0fbd00.png)

in fact, I even wanted to connect a remote docker socket via ssh

- --providers.docker.endpoint=ssh://user@192.168.1.10

but it didn 't work out to connect to the socket either , so I decided to experiment on the same host where kubernetes put docker

by look at how to understand such a picture? there are a lot of providers there , I thought traefik could connect them all at the same time

adding configuration according to k3s instructions and traefik commands

```auto
https://docs.k3s.io/helm

```

---

<div class="post-metadata">

**Author:** ![PahaCore](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/pahacore/32/6998_2.png) [@PahaCore](https://community.traefik.io/u/PahaCore)\
**Post date:** [April 19, 2023, 10:17am UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303/9 "2023-04-19T10:17:15Z")

</div>

I installed k3s without traefik  
installing it separately traefik через yaml  
it turned out the same thing  
probably it won't work ☹  
I wanted to serve different providers with one proxy server

---

<div class="post-metadata">

**Author:** ![PahaCore](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/pahacore/32/6998_2.png) [@PahaCore](https://community.traefik.io/u/PahaCore)\
**Post date:** [April 20, 2023, 5:29am UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303/10 "2023-04-20T05:29:11Z")

</div>

I noticed that the processes in the pod go under the name traefik

I think we need to create a traefik user and give him docker rights

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [April 20, 2023, 5:44am UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303/11 "2023-04-20T05:44:53Z")

</div>

Traefik providers enable dynamic Traefik configuration. Just because you can enable all providers, does not mean you should enable all providers.

I personally doubt that the Docker socket is available in a k3s environment. K3s can run Docker containers, but I am not sure the underlaying Docker APIs are available, because k3s handles the container management.

---

<div class="post-metadata">

**Author:** ![PahaCore](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/pahacore/32/6998_2.png) [@PahaCore](https://community.traefik.io/u/PahaCore)\
**Post date:** [April 20, 2023, 8:07am UTC](https://community.traefik.io/t/adding-a-docker-provider-to-traefik-k3s-error-docker-sock-access/18303/12 "2023-04-20T08:07:24Z")

</div>

I decided to go the other way - through the file provider

```auto
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
  name: traefik
  namespace: kube-system
spec:
  valuesContent: |-
    additionalArguments:
      - --accesslog=true
      - --global.checknewversion
      - --providers.file.directory=/file
      - --entryPoints.vpn.address=:51820/udp
      - --entrypoints.web.http.redirections.entryPoint.to=:443
      - --entrypoints.web.http.redirections.entryPoint.scheme=https
    volumes:
      - name: config-file
        mountPath: file/
        type: configMap

```

```auto
apiVersion: v1
kind: ConfigMap
metadata:
  name: config-file
  namespace: kube-system
data:
  vpn.yaml: |-
    udp:
      routers:
        vpn-router:
          entryPoints:
            - vpn
          service: vpn-service
      services:
        vpn-service:
          loadBalancer:
            servers:
            - address: 192.168.88.3:51820

```

 ![image](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/4/4a2b7a989bf3e87ea2550af523190ac673e97db6.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/0/025d0eb303551435977bd60b22d776dea60d620c.png)

everything is fine  
, but the traffic does not go - it does not return from the service  
firewalls everything is ok  
if you connect inside a local network, everything works

the server itself means ok

the problem with Traefik - what could be wrong now?
