portainer: Warning Messages in Portainer Logs Caused by docker.sock not Available in Docker Swarm Setting
Bug description There are warning messages in the Portainer Container log.
Expected behavior There should not be such a warning message in the Portainer Container log.
Portainer Logs 2023/04/18 01:07PM WRN platform/platform.go:68 > failed to retrieve docker info | error=“Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?”
Steps to reproduce the issue:
- Have Portainer for a single node docker swarm using the official manual: https://docs.portainer.io/start/install-ce/server/swarm/linux
- Check the Logs of the Portainer Container using Portainer
- Notice the warning messages in the Portainer Container Log.
Technical details:
- Portainer version: 2.18.1 (CE)
- Docker version (managed by Portainer): 23.0.4
- Platform (windows/linux): linux
Additional information
The changes introduced by #8095 to DetermineContainerPlatform
in api/platform/platform.go
(https://github.com/portainer/portainer/pull/8095/files#diff-1de261cf96cf89923c3d864d51e93cb0910700fa0f749bf85ab8167eefdee1b5R37) triggers docker info since that change.
Using the recommended install manual for swarm scenario, the docker.sock will not be mounted into the Portainer container but only to the agent container.
I guess this is causing the warning messages in the Portainer Container Log.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 19
- Comments: 34 (5 by maintainers)
Hi and I am not very familiar with Go but I looked up the code and I think the issue is that a simple docker client is created here: https://github.com/portainer/portainer/blob/develop/api/platform/platform.go#L59
In that case the DefaultDockerHost is used which is unix:///var/run/docker.sock.
You can override that with the DOCKER_HOST environment variable but that does not work either because the simple client refers to the DefaultDockerHost. The warning occurs also each time the Info-Endpoint is called via REST which is quite often 😃
IMHO this should not be a warning. We use a docker socket proxy in between, so we don’t mount the socket directly: https://github.com/Tecnativa/docker-socket-proxy
Alternatively it would be nice to make that overridable.
@jamescarppe Sadly, the recently released 2.20.0 version is still suffering from this issue.
Even when using the standard officially documented installation method for Docker Swarm here: https://docs.portainer.io/start/install-ce/server/swarm/linux#deployment
Portainer starts to spam the logs frequently (more than once per minute) as seen below:
The problem manifests when the Portainer server container does not have
/var/run/docker.sock
mounted in it, which is not necessary when using Portainer with a remote Portainer agent, as it goes via network. In fact, even when using Portainer in standalone mode (without containers) it should manifest if the user is running Portainer without Docker running locally.The problem is in the
DetermineContainerPlatform()
function here: https://github.com/portainer/portainer/blob/61642b8df610712c3cd71efc0e792c53627878d2/api/platform/platform.go#L39-L82As it can be seen, this function tries to create a client to a Docker daemon unconditionally in line 59. I believe that instead, Portainer should check if
/var/run/docker.sock
(or more generically, DOCKER_HOST) exists before attempting to do this, and skip the rest of the detection if the socket is not available.I understand the Portainer team is already working on this (
Internal Ref: EE-5372
) for a while, but it has been a really long while as of now and the log spamming is really an important issue for us (and I think lots of users conscious of log storage space).We haven’t been able to migrate from Portainer 2.14.x due to this (and another) issue. I hope this can be fixed once and for all sooner than later before the new LTS hits. Thanks!
@jamescarppe @tamarahenson Is there any update on this issue or a time schedule regarding a fix? 🙂
Not sure if that’s helpful and even the fix for the root cause but I came around the issue by adding into the offical portainer-agent-stack.yml yaml:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
Since then the warning disappered and I was able to connect properly to the portainer environement (before just an empty portainer had been presented)
Internal Ref: EE-5372
+1 …I got this problem (continual error in my logs) too.
+1
same issue on docker swarm use portainer-agent-stack.yml my test doesn’t have any worker, only 1 manager
portainer_agent
portainer_portainer
portainer version
2.19.4 (CE)
docker version
Hi there, everyone! I’m experiencing the same issue on version 2.19.3-alpine. Do you have any expectations on when it could be fixed?
I use Docker version 24.0.7
I was using portainer-ee:218.2 and did not realize any problem, but after upgrading to 2.19.1 log is flooded with theese two errors: 2023/09/22 03:22PM INF docker/snapshot.go:180 > unable to inspect container in other Swarm nodes | error=“Error response from daemon: No such container: d70efd1405298804dc09d3b72e4a8b0a2463799fcbe12478bca093d2dc8a9bc4” container=d70efd1405298804dc09d3b72e4a8b0a2463799fcbe12478bca093d2dc8a9bc4
2023/09/22 03:22PM WRN platform/platform.go:70 > failed to retrieve docker info | error=“Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?”
I can’t say it’s harmless, sometimes the portainer is not showing the “stats” and “exec console” icons at container. and then show after refresh
not sure how to downgrade, if I just deploy the 2.18.2 it’s not working, I see the stacks, but cant go into the stack (error was something like it can’t read compose.yml file)
2 node docker swarm, Docker version 23.0.6
+1
Any update on this?
When i add, volumes: - /var/run/docker.sock:/var/run/docker.sock to portainer-agent-stack.yml file, my system also see 2 environments, swarm and local. swarm comes from the yml file as expected but the added docker.sock creates local environment.
The warning comes periodically as well with 2.18.3 when using Docker Standalone > API with a Docker API URL as environment.
Issue is stiil actual for 2.18.3
Just a heads-up that this issue is still present in the newly released
2.18.3
version as well 😦There are periodic error messages in the console logs:
This has the potential to fill up any logger system in place for Portainer, including the default Docker logger driver that does not rotate/limit logs by default.