Table of Contents

About

In case you are wondering what the containers are, they correspond to the servarr complete stack and "ctop" was added to provide monitoring that will be part of the stack itself rather than using an external tool. The reason for doing so it that it eliminates the dependency on the host system and makes the stack deployable on a freshly installed system.

ctop is a commend-line utility similar to "top" or "htop" meant to supervise Docker containers. Compared to its counterpart standard utilities, "ctop" is meant to work within a container in order to monitor all other containers, which is accomplished by passing through the Docker socket. Were an utility like "htop" to be dockerized, then the container would have to run within the PID address space, share the same network or even be able to access the same block devices. However, "ctop" can be run both as a standalone Docker container or be part of a Docker swarm.

"ctop" also satisfies the necessity to have a low-resource consuming container that can monitor other Docker containers, given that tools like Prometheus or even Swarmpit, the latter relying on a bunch of databases like Influx, consume way too many resources to be able to be deployed on minimal hardware.

In terms of monitoring, "ctop" is actually fairly complete and has a built-in log-viewer along with the display of the performance statistics which makes it a tool that satisfies most of the supervising tasks that one could do for Docker.

Displaying the Console

Since "ctop" is a console tool, something extra is needed to display the console over HTTP and that additional extra is ttyd that this container uses to display "ctop". "ttyd" also provides a way to perform basic authentication for some built-in protection in case the service will be exposed to a wider network.

Usage

Building is a matter of issuing:

docker build -t TAG .

where:

Note that if the image is to be deployed to a swarm, then more than likely the image should be committed to a local registry serving the local docker swarm.

Source

FROM debian:stable-slim
 
# update package manager
RUN  apt-get update -y && \
     apt-get upgrade -y && \
     apt-get dist-upgrade -y && \
     apt-get -y autoremove && \
     apt-get clean
 
# UTF-8 support
RUN apt-get install -y coreutils locales && \
    sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
    locale-gen && \
    dpkg-reconfigure --frontend=noninteractive locales && \
    update-locale LANG=en_US.UTF-8
 
# set environment variables
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8
 
# install required packages
RUN apt-get install -y \
    curl \
    jq
 
# install ctop    
WORKDIR /tmp
RUN curl -sL "https://api.github.com/repos/bcicen/ctop/releases/latest" | \
    jq -r '.assets[] | select (.name | contains("linux-amd64")) | .browser_download_url' | \
    xargs curl -sLo file && \
    mv file /usr/local/bin/ctop && \
    chmod +x /usr/local/bin/ctop && \
    ls -l /usr/local/bin/ctop
 
# isntall ttyd
RUN curl -sL "https://api.github.com/repos/tsl0922/ttyd/releases/latest" | \
    jq -r '.assets[] | select (.name | contains("x86_64")) | .browser_download_url' | \
    xargs curl -sLo file && \
    mv file /usr/local/bin/ttyd && \
    chmod +x /usr/local/bin/ttyd && \
    ls -l /usr/local/bin/ttyd
 
# clean up
RUN apt-get purge -y \
    jq
RUN apt-get -y autoremove
 
EXPOSE 7681
 
ENTRYPOINT /usr/local/bin/ttyd --credential ${USERNAME:-admin}:${PASSWORD:-admin} -W /usr/local/bin/ctop