by Devin Yang
(This article was automatically translated.)

Published - 3 years ago ( Updated - 2 years ago )

Update 2022-11-06
There is an HTML5 graphical speed test software, you can try it if you are interested, it also supports Docker startup, it is not difficult to use.
HTML5 Internet Speed ​​Test.
The biggest advantage of this software can be used to verify the speed of others connecting to your host.
In my experience, through this software, I found that there is a problem with the network cable of the intranet, and it cannot run to 1G.
After changing the network cable, it can run to 1G, which is quite easy to use. 😄

https://openspeedtest.com/
< br>==== The following is old information ===
How to simply use Docker to create an internet command line speed test program?

Here we use the python program speedtest-cli

br>I will use Docker for the main use case, for example, I want to measure the speed in my NAS.
Although there is python in my NAS, but there is no pip command, it feels much safer to use Docker at this time.
Of course, the first question Your NAS needs to be able to run Docker :).

Or, I am in a MacOS environment and I don't want to install speedtest-cli into my MacOS.

At this time, it is not bad to use Docker to build a simple execution environment by yourself.

1. First create a Dockerfile file, the content is as follows, this Dockerfile is used to build our own Image

FROM python:rc-alpine3.13
RUN pip3 install speedtest-cli
CMD speedtest-cli

Just use a smaller image here.
The first line is based on the official python image.
The second line, install speedtest-cli into the image through pip3
The third line, execute speedtest-cli, when the container is created and executed, it will run.

Second, let's build your own image now, please put the Dockerfile in a self-built directory and execute it.

docker build -t deviny/speedtest .

The deviny/speedtest after -t here is the name of my image
Schematic diagram:

Or, you can paste the command below to One line of the terminal is done to create an image named speedtest.

mkdir speedtest&&cd speedtest&&docker build -t speedtest -<<EOF
FROM python:rc-alpine3.13
RUN pip3 install speedtest-cli
CMD speedtest-cli
EOF

Schematic diagram:

< br>Third, because I have a Dockerhub account, I can push to Dockerhub. (Optional, not necessary)
In this way, I can run docker run in other places where I have a Docker environment.

docker push deviny/speedtest

Fourth, execute the speed test command

docker run --rm deviny/speedtest

The --rm here represents that the container will be deleted after execution.
The schematic diagram is as follows:

Testing from Chunghwa Telecom (211.72.111.169)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Chunghwa Mobile (Taipei) [1.62 km]: 5.098 ms
Testing download speed................................................... ...................................
Download: 247.98 Mbit/s
Testing upload speed................................................... ................................................... .....
Upload: 102.39 Mbit/s


In the third step, I have uploaded the image to dockerhub. In other words, you can directly execute the instructions in the fourth step and it will run . :)
So we can add an alias for the next execution.

alias speedtest="docker run --rm deviny/speedtest"

If the name you use is speedtest, the command It should be as follows 

docker run --rm speedtest


 

Tags: docker

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


docker

Install docker-compose on ubuntu

Briefly introduce how I installed docker-compose on ubuntu. Quite easy.

docker

Update docker-compose version with bash

Install the latest version of docker-compose

d-laravel,docker

D-Laravel v1.2.1 version change description (recommended update, must avoid stepping on thunder)

D-Laravel v1.2.1 revision instructions use GuzzleHttp\Client; When posting, there is an access denied problem. If you are upgrading from an older version, you may need to adjust the configuration file in etc/default-ssl.conf (if there is one) Please adjust php:9000 to web:9000, you can adjust it by executing ./console secure once. In the docker-compose configuration file, change the PHP-FPM container to network_mode: "service:web"...