Dal
March 7, 2024, 11:48am
1
Hi.
I'm struggling to get traefik running properly.
It cannot connect to the docker daemon, and gives me these errors:
level=error msg="Failed to retrieve information of the docker client and server host: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" providerName=docker
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 10.921124173s" providerName=docker
I run the docker container as non-root, with a username dockeruser.
I have run the commands:
sudo groupadd docker
sudo usermod -aG docker $USER
And everything seems to run fine otherwise. I have other containers up and running
In the traefik docker compose file I have set this:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
Any tips?
thank you
Share your full Traefik static and dynamic config, and docker-compose.yml
if used.
Which user is active inside Docker container?
Dal
March 7, 2024, 12:59pm
3
Hi, thanks for answering.
Her is a link to traefik.yml
and a link to fileConfig.yml
Here is the docker-compose.yml
How do I know for sure what user is active inside the docker?
It is supposed to be "dockeruser"
The user should have access.
When running the command stat /var/run/docker.sock , it says:
stat /var/run/docker.sock
File: /var/run/docker.sock
Size: 0 Blocks: 0 IO Block: 4096 socket
Device: 17h/23d Inode: 697 Links: 1
Access: (0660/srw-rw----) Uid: ( 0/ root) Gid: ( 997/ docker)
Access: 2024-03-07 14:02:36.128012382 +0100
Modify: 2024-02-26 14:55:19.239746804 +0100
Change: 2024-02-26 14:55:19.243746804 +0100
and the user docker user is member of the docker group, as stated by groups dockeruser :
dockeruser : dockeruser sudo docker
Running inside or outside the container?
Note that you can't have multiple traefik static config, either traefik.yml
, compose command
or env vars,
Dal
March 7, 2024, 2:33pm
5
Not sure what happened, but after a apt update && apt upgrade and a reboot, it seems that the errors are gone.
I see this in the log:
Provider connection established with docker 25.0.4 (API 1.44)" providerName=docker
I'm guessing that is a good thing.
But I still cannot see other containers in the traefik dashboard.
For example code_server:
version: "3.8"
services:
code_server:
container_name: code_server
restart: unless-stopped
image: lscr.io/linuxserver/code-server:latest
networks:
- elastic
volumes:
- ./data:/config
- /home/dockeruser/docker:/1_Docker_Containers
labels:
traefik.enable: true
traefik.http.routers.code_server.rule: Host("cs.domain.tld")
traefik.http.routers.code_server.entryPoints: https
traefik.http.routers.code_server.tls: true
environment:
- TZ=Europe/Oslo
- PASSWORD=Password02
- PUID=1001
- PGID=1001
ports:
- 8444:8443
networks:
elastic:
external: true
Dal
March 7, 2024, 2:34pm
6
bluepuma77:
Note that you can't have multiple traefik static config, either traefik.yml
, compose command
or env vars,
I'm aware. And as far as I know, I don't have any multiple entries active. There are a bunch that are commented out, though
You labels are in JSON style, but need to be in ENV VAR style.
Dal
March 7, 2024, 7:01pm
8
You mean like this:
labels:
- traefik.enable = true
- traefik.http.routers.code-server.rule = Host('cs.domain.tld')
- traefik.http.routers.code-server.entryPoints = https
- traefik.http.routers.code-server.tls = true
Didn't help
Like this:
labels:
- traefik.enable=true
- traefik.http.routers.mywhoami.rule=Host(`whoami.example.com`)
- traefik.http.services.mywhoami.loadbalancer.server.port=80
Source: simple Traefik example
Dal
March 7, 2024, 7:41pm
10
This did the trick!
Aaah, hours and hours banging head against the wall are finally over!
Thank you, thank you, THANK YOU
system
Closed
March 10, 2024, 7:41pm
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.