Skip to content

Add container support for Docker Swarm environments #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
j0nathanr opened this issue Mar 7, 2025 · 3 comments
Open

Add container support for Docker Swarm environments #403

j0nathanr opened this issue Mar 7, 2025 · 3 comments

Comments

@j0nathanr
Copy link

Description

Currently, Glance uses the local docker socket to gather container information on the system it's running on. In a docker swarm environment, containers are distributed across multiple hosts (nodes) as docker services. As a result, Glance does not display all labeled docker containers running in the swarm, only the containers currently running on the same node as it is.

The glance agent could be used and deployed globally in the swarm too send container information to the Glance app. This can work the same way services like Portainer and Swarmpit gather container information using their agents. From Portainer's GitHub page:

The Portainer agent is basically a cluster of Docker API proxies. Deployed inside a Swarm cluster on each node, it allows the redirection (proxy) of a Docker API request on any specific node as well as the aggregration of the response of multiple nodes.

I see no potential downsides as swarm mode can be enabled via an environmental variable which defaults to false. Anyone outside a docker swarm environment can simply omit any swarm related configurations.

@mortonpd
Copy link

For Docker swarms, would a widget that uses a method closer to traefiks swarm mode not be more appropriate where labels are found on the services rather than on the containers.

This removes the need for agents - but does mean that glance would need to be deployed to a 'manager' node to access the swarm API.

@j0nathanr
Copy link
Author

That does seem more appropriate considering the current implementation of docker container support also requires labels. The need to run it on a manager node is fine since the agent route would run on every swarm node anyhow, this just means less overhead.

@kuhree
Copy link

kuhree commented Mar 25, 2025

Hey 👋 , I also wanted to see this. Just put up a PR with a solution I'm using locally. Would love some feedback if it works for you or not.

Here's a docker image if you're interested: ghcr.io/kuhree/glance:pr-517

Here's how the config looks:

- type: docker-containers
  mode: swarm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants