by Devin Yang
(This article was automatically translated.)

Published - 3 years ago ( Updated - 1 year 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

Devin Yang's Notes for Beginners with Docker

These are my notes when I first learned Docker. It is a bit rough and I have adjusted it a bit. But I think for Docker beginners, it should be able to provide some preliminary concepts, Welcome to refer to it.

docker,php,cli

MacOS's php is not powerful, use docker to execute laravel installer

It's very simple, just add an "alias" alias laravel='docker run --rm -v ${PWD}:/var/www/html -v ~/.dlaravel/cache:/home/dlaravel/.composer /cache -ti deviny/fpm:8.1.10 /home/dlaravel/.composer/vendor/bin/laravel'

docker

About how to change the owner of FPM image on GCE

The CCC website has been upgraded to php 7.2.0. With a Docker environment, it is easy to upgrade php. There are still some precautions you should know about the change of Image on Linux. If you install D-Laravel on a Linux system through docker like me, when you change a different image, Perhaps you may encounter, doubt! Why composer does not have permission to write to the folder error. directory is not writable