From ba932e72bdbb447c5eceef9c6e66c20aaf547acc Mon Sep 17 00:00:00 2001 From: nicolargo Date: Tue, 30 Dec 2025 10:40:36 +0100 Subject: [PATCH] Read only container (with docker-compose) #3382 --- README.rst | 77 ++++++++++--------- docker-compose/Dockerfile | 3 - .../docker-compose-with-traefik.yml | 40 ---------- docker-compose/docker-compose.yml | 43 ++++++++--- 4 files changed, 71 insertions(+), 92 deletions(-) delete mode 100644 docker-compose/Dockerfile delete mode 100644 docker-compose/docker-compose-with-traefik.yml diff --git a/README.rst b/README.rst index bf4b243a..2adf580c 100644 --- a/README.rst +++ b/README.rst @@ -255,14 +255,14 @@ PyPI: Pip, the standard way Glances is on ``PyPI``. By using PyPI, you will be using the latest stable version. -To install Glances, simply use the ``pip`` command line. - -Warning: on modern Linux operating systems, you may have an externally-managed-environment -error message when you try to use ``pip``. In this case, go to the the PipX section below. +To install Glances, simply use the ``pip`` command line in an virtual environment. .. code-block:: console - pip install --user glances + cd ~ + python3 -m venv ~/.venv + source ~/.venv/bin/activate + pip install glances *Note*: Python headers are required to install `psutil`_, a Glances dependency. For example, on Debian/Ubuntu **the simplest** is @@ -271,17 +271,18 @@ the *python-dev* package and gcc (*python-devel* on Fedora/CentOS/RHEL). For Windows, just install psutil from the binary installation file. By default, Glances is installed **without** the Web interface dependencies. + To install it, use the following command: .. code-block:: console - pip install --user 'glances[web]' + pip install 'glances[web]' For a full installation (with all features, see features list bellow): .. code-block:: console - pip install --user 'glances[all]' + pip install 'glances[all]' Features list: @@ -306,21 +307,18 @@ To upgrade Glances to the latest version: .. code-block:: console - pip install --user --upgrade glances - -The current develop branch is published to the test.pypi.org package index. -If you want to test the develop version (could be instable), enter: - -.. code-block:: console - - pip install --user -i https://test.pypi.org/simple/ Glances + pip install --upgrade glances PyPI: PipX, the alternative way ------------------------------- -Install PipX on your system (apt install pipx on Ubuntu). +Install PipX on your system. For example on Ubuntu/Debian: -Install Glances (with all features): +.. code-block:: console + + sudo apt install pipx + +Then install Glances (with all features): .. code-block:: console @@ -328,14 +326,11 @@ Install Glances (with all features): The glances script will be installed in the ~/.local/bin folder. -Brew: The missing package manager ---------------------------------- - -For Linux and Mac OS, it is also possible to install Glances with `Brew`_: +To upgrade Glances to the latest version: .. code-block:: console - brew install glances + pipx upgrade glances Docker: the cloudy way ---------------------- @@ -343,12 +338,6 @@ Docker: the cloudy way Glances Docker images are available. You can use it to monitor your server and all your containers ! -Get the Glances container: - -.. code-block:: console - - docker pull nicolargo/glances:latest-full - The following tags are available: - *latest-full* for a full Alpine Glances image (latest release) with all dependencies @@ -393,13 +382,32 @@ Run the container in *Web server mode*: For a full list of options, see the Glances `Docker`_ documentation page. +It is also possible to use a simple Docker compose file (see in ./docker-compose/docker-compose.yml): + +.. code-block:: console + + cd ./docker-compose + docker-compose up + +It will start a Glances server with WebUI. + +Brew: The missing package manager +--------------------------------- + +For Linux and Mac OS, it is also possible to install Glances with `Brew`_: + +.. code-block:: console + + brew install glances + GNU/Linux package ----------------- `Glances` is available on many Linux distributions, so you should be -able to install it using your favorite package manager. Be aware that -when you use this method the operating system `package`_ for `Glances` -may not be the latest version and only basics plugins are enabled. +able to install it using your favorite package manager. Nevetheless, +i do not recommend it. Be aware that when you use this method the operating +system `package`_ for `Glances`may not be the latest version and only basics +plugins are enabled. Note: The Debian package (and all other Debian-based distributions) do not include anymore the JS statics files used by the Web interface @@ -418,7 +426,6 @@ Check for Python version: # python --version - Install the Glances package: .. code-block:: console @@ -464,11 +471,7 @@ Windows ------- Install `Python`_ for Windows (Python 3.4+ ship with pip) and -then run the following command: - -.. code-block:: console - - $ pip install glances +follow the Glances Pip install procedure. Android ------- diff --git a/docker-compose/Dockerfile b/docker-compose/Dockerfile deleted file mode 100644 index 51cbff4f..00000000 --- a/docker-compose/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM glances:local-alpine-minimal as glancesminimal -COPY glances.conf /glances/conf/glances.conf -CMD python -m glances -C /glances/conf/glances.conf $GLANCES_OPT diff --git a/docker-compose/docker-compose-with-traefik.yml b/docker-compose/docker-compose-with-traefik.yml deleted file mode 100644 index 06caf682..00000000 --- a/docker-compose/docker-compose-with-traefik.yml +++ /dev/null @@ -1,40 +0,0 @@ -version: "3.9" -services: - reverse-proxy: - image: traefik - command: --api --docker - ports: - - "80:80" - - "8080:8080" - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - whoami: - image: emilevauge/whoami - labels: - - "traefik.frontend.rule=Host:whoami.docker.localhost" - - monitoring: - image: nicolargo/glances:dev - restart: unless-stopped - pid: host - privileged: true - network_mode: "host" - volumes: - - "/var/run/docker.sock:/var/run/docker.sock:ro" - - "/run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro" - - "./glances.conf:/glances/conf/glances.conf" - environment: - - TZ=${TZ} - - "GLANCES_OPT=-C /glances/conf/glances.conf -w" - # Uncomment for GPU compatibility (Nvidia) inside the container - # deploy: - # resources: - # reservations: - # devices: - # - driver: nvidia - # count: 1 - # capabilities: [gpu] - labels: - - "traefik.port=61208" - - "traefik.frontend.rule=Host:glances.docker.localhost" diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index b0e32e47..55fa9c06 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -1,23 +1,41 @@ -version: '3.9' services: glances: - build: - context: ./ - dockerfile: Dockerfile + # See all images tags here: https://hub.docker.com/r/nicolargo/glances/tags + image: nicolargo/glances:latest-full restart: always + pid: "host" - privileged: true network_mode: "host" + + read_only: true + privileged: false + # Uncomment next line for SATA or NVME smartctl monitoring + # cap_add: + # Uncomment next line for SATA smartctl monitoring + # - SYS_RAWIO + # Uncomment next line for NVME smartctl monitoring + # - SYS_ADMIN + # devices: + # - "/dev/nvme0" + volumes: + - "/:/rootfs:ro" - "/var/run/docker.sock:/var/run/docker.sock:ro" - "/run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro" - "./glances.conf:/glances/conf/glances.conf" -# # Uncomment for proper distro information in upper panel. + # Uncomment for proper distro information in upper panel. # # Works only for distros that do have this file (most of distros do). # - "/etc/os-release:/etc/os-release:ro" + + tmpfs: + - /tmp + environment: - - TZ=${TZ} - - GLANCES_OPT=-C /glances/conf/glances.conf -w + # Please set to your local timezone (or use local ${TZ} environment variable if set on your host) + - TZ=Europe/Paris + - GLANCES_OPT=-C /glances/conf/glances.conf -w --enable-plugin smart + - PYTHONPYCACHEPREFIX=/tmp/py_caches + # # Uncomment for GPU compatibility (Nvidia) inside the container # deploy: # resources: @@ -26,10 +44,11 @@ services: # - driver: nvidia # count: 1 # capabilities: [gpu] -# # Uncomment to protect Glances WebUI by a login/password (add --password to GLANCES_OPT) -# secrets: -# - source: glances_password -# target: /root/.config/glances/.pwd + + # Uncomment to protect Glances WebUI by a login/password (add --password to GLANCES_OPT) + # secrets: + # - source: glances_password + # target: /root/.config/glances/.pwd # secrets: # glances_password: