Skip to content

Podman containers monitoring support #1985

@carbolymer

Description

@carbolymer

Is your feature request related to a problem? Please describe.
When using podman instead of docker, glances fails with an exception.

Describe the solution you'd like
Glances should not fail to start. Podman containers should be visible in a similar manner as docker containers. Podman supports Docker API v1.40: https://docs.podman.io/en/latest/markdown/podman-system-service.1.html

Describe alternatives you've considered
n/a

Additional context
n/a

Steps to reproduce

  1. Install podman
  2. Enable podman service `systemctl start --user podman.service
  3. Set DOCKER_HOST environment variable:
export XDG_RUNTIME_DIR=/run/user/$(id -u)  # this should not be needed - XDG_RUNTIME_DIR should be already set on your system
export DOCKER_HOST="unix://$XDG_RUNTIME_DIR/podman/podman.sock"
  1. Start glances - it hangs with the following error (needs to be ctrl-c'd):
glances                                                                                                                                                                                                            
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/docker/api/client.py", line 268, in _raise_for_status
    response.raise_for_status()
  File "/usr/lib/python3.10/site-packages/requests/models.py", line 953, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.40/images/latest/json

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/glances", line 33, in <module>
    sys.exit(load_entry_point('Glances==3.2.4', 'console_scripts', 'glances')())
  File "/usr/lib/python3.10/site-packages/glances/__init__.py", line 150, in main
    start(config=core.get_config(), args= core.get_args())
  File "/usr/lib/python3.10/site-packages/glances/__init__.py", line 109, in start
    mode = GlancesMode(config=config, args=args)
  File "/usr/lib/python3.10/site-packages/glances/standalone.py", line 80, in __init__
    self.stats.update()
  File "/usr/lib/python3.10/site-packages/glances/stats.py", line 230, in update
    self._plugins[p].update()
  File "/usr/lib/python3.10/site-packages/glances/plugins/glances_plugin.py", line 1151, in wrapper
    ret = fct(self, *args, **kw)
  File "/usr/lib/python3.10/site-packages/glances/plugins/glances_plugin.py", line 1166, in wrapper
    ret = fct(*args, **kw)
  File "/usr/lib/python3.10/site-packages/glances/plugins/glances_docker.py", line 250, in update
    container_stats['Image'] = container.image.tags
  File "/usr/lib/python3.10/site-packages/docker/models/containers.py", line 40, in image
    return self.client.images.get(image_id.split(':')[1])
  File "/usr/lib/python3.10/site-packages/docker/models/images.py", line 314, in get
    return self.prepare_model(self.client.api.inspect_image(name))
  File "/usr/lib/python3.10/site-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/docker/api/image.py", line 251, in inspect_image
    return self._result(
  File "/usr/lib/python3.10/site-packages/docker/api/client.py", line 274, in _result
    self._raise_for_status(response)
  File "/usr/lib/python3.10/site-packages/docker/api/client.py", line 270, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/usr/lib/python3.10/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.ImageNotFound: 404 Client Error for http+docker://localhost/v1.40/images/latest/json: Not Found ("failed to find image latest: latest: No such image")
^CException ignored in: <module 'threading' from '/usr/lib/python3.10/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1560, in _shutdown
    lock.acquire()
  File "/usr/lib/python3.10/site-packages/glances/__init__.py", line 69, in __signal_handler
    end()
  File "/usr/lib/python3.10/site-packages/glances/__init__.py", line 84, in end
    sys.exit(0)
SystemExit: 0

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions