Barry Evans cd68f3e4cf Fix docker build - apt-get install speedtest failing
When building the image I am seeing problems trying to install the
speedtest package. This is fixed by using the current installation
command from the speedtest website:
- https://www.speedtest.net/apps/cli
- ```
  RUN curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | bash
  RUN apt-get install -y speedtest
  ```

---

Build error log:

```shell
docker build -t robinmanuelthiel/speedtest:latest .
[+] Building 18.5s (9/10)                                                                                        docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                             0.0s
 => => transferring dockerfile: 335B                                                                                             0.0s
 => [internal] load metadata for docker.io/library/debian:bullseye                                                               1.5s
 => [auth] library/debian:pull token for registry-1.docker.io                                                                    0.0s
 => [internal] load .dockerignore                                                                                                0.0s
 => => transferring context: 2B                                                                                                  0.0s
 => CACHED [1/5] FROM docker.io/library/debian:bullseye@sha256:2c7a92a41cb814c00e7d455b2bc0c90ccdb9a4ced2ffdc10e562c7a84a186032  0.0s
 => [internal] load build context                                                                                                0.0s
 => => transferring context: 34B                                                                                                 0.0s
 => [2/5] RUN apt-get update && apt-get install -y curl jq gnupg1 apt-transport-https dirmngr                                    11.1s
 => [3/5] RUN curl -s https://install.speedtest.net/app/cli/install.deb.sh | bash                                                5.3s
 => ERROR [4/5] RUN apt-get install speedtest                                                                                    0.5s
------
 > [4/5] RUN apt-get install speedtest:
0.094 Reading package lists...
0.390 Building dependency tree...
0.458 Reading state information...
0.501 E: Unable to locate package speedtest
------
Dockerfile:8
--------------------
   6 |     # Install speedtest cli
   7 |     RUN curl -s https://install.speedtest.net/app/cli/install.deb.sh | bash
   8 | >>> RUN apt-get install speedtest
   9 |
  10 |     COPY ./speedtest.sh .
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get install speedtest" did not complete successfully: exit code: 100

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/tur2dm7wqi33zu9shh9s5zepd
```
2024-05-30 17:22:21 +09:00
2022-01-17 14:20:53 +01:00
2023-06-16 18:04:36 +02:00
2020-04-18 10:52:57 +02:00
2020-04-17 16:06:12 +02:00
2023-06-16 18:04:36 +02:00
2021-12-18 23:58:07 +01:00

Internet Speed Test in a Container

Docker

Check your internet bandwidth using the Speedtest CLI from a Docker container. You can configure the tool to run periodically and save the results to an InfluxDB for visualization or long-term records.

docker run --rm robinmanuelthiel/speedtest:latest

The result will then look like this:

Running a Speed Test...
Your download speed is 334 Mbps (29284399 Bytes/s).
Your upload speed is 42 Mbps (4012944 Bytes/s).
Your ping is 6.223 ms.

Configuration

Environment variable Default value Description
LOOP false Run Speedtest in a loop
LOOP_DELAY 60 Delay in seconds between the runs
DB_SAVE false Save values to InfluxDB
DB_HOST http://localhost:8086 InfluxDB Hostname
DB_NAME speedtest InfluxDB Database name
DB_USERNAME admin InfluxDB Username
DB_PASSWORD password InfluxDB Password

Grafana and InfluxDB

Screenshot of a Grafana Dashboard with upload and download speed values

For a full visualization and long term tracking, I recommend InfluxDB as a time-series database and Grafana as a dashboard engine. Both come in Docker containers, so the whole setup can be achieved by starting a Docker Compose file.

version: "3"
services:
  grafana:
    image: grafana/grafana:7.5.2
    restart: always
    ports:
      - 3000:3000
    volumes:
      - grafana:/var/lib/grafana
    depends_on:
      - influxdb

  influxdb:
    image: influxdb:1.8.3
    restart: always
    volumes:
      - influxdb:/var/lib/influxdb
    ports:
      - 8083:8083
      - 8086:8086
    environment:
      - INFLUXDB_ADMIN_USER="admin"
      - INFLUXDB_ADMIN_PASSWORD="password"
      - INFLUXDB_DB="speedtest"

  speedtest:
    image: robinmanuelthiel/speedtest:latest
    restart: always
    environment:
      - LOOP=true
      - LOOP_DELAY=1800
      - DB_SAVE=true
      - DB_HOST=http://influxdb:8086
      - DB_NAME=speedtest
      - DB_USERNAME=admin
      - DB_PASSWORD=password
    privileged: true # Needed for 'sleep' in the loop
    depends_on:
      - influxdb

volumes:
  grafana:
  influxdb:

To configure Grafana, we need to add InfluxDB as a data source and create a dashboard with the upload and download values. You can find a demo dashboard configuration in the /demo folder.

Hint: The speedtest outputs values as bytes per second. Make sure to divide all values by 125000 in your dashboard to get the Mbps values.

S
Description
Check internet bandwidth from a Docker container and save the results to an InfluxDB
Readme MIT
210 KiB
Languages
Shell 90.3%
Dockerfile 9.7%