Deployment with Docker

Running gtop inside a Docker container is an excellent way to use the tool without installing Node.js or other dependencies directly on your host machine. The official gtop image is available on Docker Hub.

Running the Docker Container

To monitor the host system from within the container, you must grant the container access to the host's network and process ID (PID) namespaces.

Use the following command to run gtop:

docker run --rm -it \
    --name gtop \
    --net="host" \
    --pid="host" \
    aksakalli/gtop

Command Breakdown

  • docker run: The standard command to create and start a new container.
  • --rm: Automatically removes the container when it exits, keeping your system clean.
  • -it: Runs the container in interactive mode and allocates a pseudo-TTY, which is necessary for terminal-based applications like gtop.
  • --name gtop: Assigns a convenient name to the container.
  • --net="host": Shares the host's network namespace with the container. This allows gtop to monitor the host's network interfaces.
  • --pid="host": Shares the host's PID namespace with the container. This is crucial for gtop to see and monitor processes running on the host.
  • aksakalli/gtop: The name of the official Docker image to pull from Docker Hub.

Dockerfile

For those interested in how the image is built, here is the source Dockerfile:

FROM node:15-alpine

RUN apk --no-cache add procps
ENV LANG=en_US.utf8 \
    TERM=xterm-256color

COPY lib lib
COPY bin bin
COPY package.json .
COPY package-lock.json .

RUN npm install --production
ENTRYPOINT ["./bin/gtop"]