Portainer Templates logo

Portainer Templates

Glances Glances

Stack

Monitoring

Glances is an open-source system cross-platform monitoring tool. It allows real-time monitoring of various aspects of your system such as CPU, memory, disk, network usage etc.

Image details

Pulls: 118.6M
Architecture: amd64, arm64
Image size: 147 MB
Latest: 4.5.6-full
User: nicolargo
Created: Nov 27, 2015
Updated: 14 hours ago
Status: active

Source details

Stars: 33.4k
Forks: 2k
Language: Python
Updated: 15 hours ago

Configuration

Type
Compose
Platform
linux
Image
nicolargo/glances:latest-alpine
Volumes
/var/run/docker.sock : /var/run/docker.sock
Env vars
GLANCES_OPT=-w
Restart
always
Source

Template by xneo1·Source

Standalone Install

Select an install method, to see config/commands for deploying Glances

Installation method

Install on Portainer

Import all app templates into your Portainer instance, for easy 1-click deploys

  1. Ensure both Docker and Portainer are installed, and up-to-date
  2. Log into your Portainer web UI
  3. Under Settings → App Templates, paste the below URL
  4. Head to Home → App Templates, and the list of apps will show up
  5. Select Glances, fill in any config options, and hit Deploy

Template Import URL

https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates.json
Show Me demo
Original stackfile

The compose file this template deploys, straight from its repo:

services:
  glances-monitoring:
    image: nicolargo/glances:latest-alpine
    restart: always
    pid: host
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - "GLANCES_OPT=-w"

Or deploy it directly from the source:

git clone https://github.com/xneo1/portainer_templates
cd portainer_templates
docker compose -f Template/Stack/glances.yml up -d

More install options in our documentation, or see nicolargo/glances for app-specific guidance.

Glances - An eye on your system

Glances is an open-source software designed to monitor your host (where the container is ran) and all others containers.
Users can use a console or web based user interface and export stats to CSV/JSON files or time-series databases.

Quick start

Pull the full development version (ubuntu-dev or alpine-dev tags):
docker pull nicolargo/glances:ubuntu-dev
Then run the container in console mode:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro --pid host --network host -it nicolargo/glances:ubuntu-dev
Or run the container in web ui mode:
docker run -d --restart="always" -p 61208-61209:61208-61209 -e GLANCES_OPT="-w" -v /var/run/docker.sock:/var/run/docker.sock:ro -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro --pid host nicolargo/glances:ubuntu-dev

Multiple versions are available

Get the Glances container:
docker pull nicolargo/glances:<version>
Available tags:
  • latest-full for a full Alpine Glances image (latest release) with all dependencies
  • ubuntu-latest-full for a full Ubuntu Glances image (latest release) with all dependencies
  • ubuntu-latest for a basic Ubuntu Glances (latest release) version with minimal dependencies (FastAPI and Docker)
  • latest for a basic Alpine Glances (latest release) version with minimal dependencies (FastAPI and Docker)
  • dev for a basic Alpine Glances image (based on development branch and latest cyber security updates) with all dependencies (Warning: may be instable)
  • ubuntu-dev for a basic Ubuntu Glances image (based on development branch and latest cyber security updates) with all dependencies (Warning: may be instable)

You can also specify a version (example: 4.3.1).
Pull the latest full version:
docker pull nicolargo/glances:ubuntu-latest-full
Then run the container in console mode:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host --network host -it nicolargo/glances:ubuntu-latest-full
Run the container in Web server mode (notice the GLANCES_OPT environment variable setting parameters for the glances startup command):
docker run -d --restart="always" -p 61208-61209:61208-61209 -e GLANCES_OPT="-w" -v /var/run/docker.sock:/var/run/docker.sock:ro --pid host nicolargo/glances:ubuntu-latest-full
Alternatively, you can specify something along the same lines with docker run options:
docker run -v `pwd`/glances.conf:/glances/conf/glances.conf -v /var/run/docker.sock:/var/run/docker.sock:ro -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro --pid host -it nicolargo/glances:ubuntu-latest-full
Where \`pwd\`/glances.conf is a local directory containing your glances.conf file.

Build your own container

Additionally, if you want to use your own glances.conf file, you can create your own Dockerfile:
FROM nicolargo/glances:ubuntu-latest-full
COPY glances.conf /glances/conf/glances.conf
CMD python -m glances -C /glances/conf/glances.conf $GLANCES_OPT

Using GPU Plugin with Docker (Only Nvidia GPUs)

Complete the steps mentioned in the docker docs <https://docs.docker.com/config/containers/resource_constraints/#gpu> to make the GPU accessible by the docker engine.
With docker run
Include the --gpus flag with the docker run command.
Note: Make sure the --gpus is present before the image name in the command, otherwise it won't work.
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro --gpus --pid host --network host -it docker.io/nicolargo/glances:ubuntu-latest-full
With docker-compose
Include the deploy section in compose file as specified below in the example service definition.
version: '3'

services:
  monitoring:
    image: nicolargo/glances:ubuntu-latest-full
    pid: host
    network_mode: host
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock
    environment:
      - "GLANCES_OPT=-w"
    # For nvidia GPUs
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]

Check the logs first

Nine times out of ten the logs tell you exactly what went wrong.

  • In Portainer, go to Containers, click the container, then Logs. Or run docker logs <container>
  • Exit codes help too: 137 means killed, usually out of memory. 126 or 127 means the command inside the image is broken.

Can't reach the Docker socket

glances-monitoring talks to Docker through /var/run/docker.sock. If the logs show "permission denied while trying to connect to the Docker daemon socket", the app's user can't access it.

  • Check the socket exists on the host: ls -l /var/run/docker.sock
  • Run the container as root, or add the docker group's id to the container with group_add.

Image won't pull

Test the pull directly on the host: docker pull nicolargo/glances:latest-alpine

  • "manifest unknown" means the tag no longer exists.
  • "toomanyrequests" is the Docker Hub rate limit. Log in with docker login to raise it.
  • "no space left on device" means a full disk. Reclaim space with docker system prune

"exec format error"

This means the image was built for a different CPU architecture than your server.

  • This image supports: amd64, arm64
  • Check yours with uname -m: x86_64 is amd64, aarch64 is arm64. Raspberry Pi and other ARM boards are the usual culprits.

Container keeps restarting

The always restart policy relaunches the app after every crash, so the real error can scroll past.

  • Check the logs right after a restart, the last few lines before it died are the useful ones.
  • Get the exit code with docker inspect <container> --format '{{.State.ExitCode}}'
  • Still stuck? Redeploy once with the restart policy set to no so the failure stays visible.

Stack won't deploy

Compose stacks fail fast on small mistakes, and Portainer shows the reason just above the editor.

  • YAML only accepts spaces for indentation, a single tab breaks the whole file.

Raise an issue

Found something which isn't working as it should? Here's how to report it.

A Compose stack

Glances is a Compose stack, a set of containers defined in one file and brought up together by Portainer, then started and stopped as a single app.

The app image

An image is the app packed up ready to go, everything Glances needs bundled into one download. This template pulls nicolargo/glances:latest-alpine, which Docker fetches once (about 147 MB) and then starts your own copy from.

Where the image comes from

Docker pulls its images from registries, public libraries of ready-built apps. Glances's comes from Docker Hub, published by nicolargo.

Version tags

The bit after the colon in the image name is the version tag. This one pins latest-alpine, so every redeploy gives you that exact build until you bump it yourself.

Which machines it runs on

Every image is built for particular CPU types. This one ships for amd64, arm64, so it runs on both regular x86 servers and ARM boards like a Raspberry Pi.

Volumes

A volume is where Glances keeps its files so they survive an update or a restart. Without one, anything it saves would sit inside the container and vanish the moment it's recreated. This template mounts:

  • /var/run/docker.sock from /var/run/docker.sock on the host (a socket it talks to, not storage)

Environment variables

Environment variables are the settings you hand over when you deploy, things like a password or a timezone. Glances takes 1 of them, all with defaults you can leave alone or tweak:

  • GLANCES_OPT, defaults to -w

Restart policy

The restart policy here is always, so Docker brings Glances back up after a crash and again when the server reboots. Good for anything you want running around the clock. You can change this on the deploy screen. The choices are no (never restart), on-failure (only after a crash), unless-stopped (restart unless you stop it), and always (bring it back no matter what).

Networking

Nothing custom is set, so Glances sits on Docker's default bridge network: its own private space that reaches the outside world only through the ports it publishes.

Container name

Once it's deployed, Portainer names the container glances-monitoring. That's what you'll spot in the containers list and use in commands like docker logs glances-monitoring.

Platform

The platform is linux, the kind of system the container is built to run on. Docker and Portainer handle this on a normal Linux server.

Portainer app templates

Zooming out, this whole page comes from a Portainer app template: a short recipe telling Portainer how to set Glances up. Add the template list to Portainer once, then deploying Glances is a click rather than a wall of config.