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


php,docker,dlaravel

A brief introduction to the phpenv container environment I built

I don't have time to shoot an introduction video, so I'll just grab some pictures and introduce the container environment deviny/phpenv I use. https://github.com/DevinY/phpenvphpenv can be regarded as an evolutionary version of my previous D-Laravel open source project, conceptually extending the use of many Dlaravel operation methods. The update of the container tends to be controlled by the user to build his own image, so I am not very good at changing the version number. In fact, the php version number of D-Laravel seems to have not been changed for a long time:p

polymer,docker

D-Laravel supports index.html by default

D-Laravel's nginx environment settings support index.html by default, simply put Now, besides, D-Laravel can be used to run Laravel's Project, and it can also be used to run other Projects. Currently Apple's WebKit is already in preview for Service-Workers....

docker

Wenchat about the evolution history of my network

Hear about the evolution of my network. My GCP costs $46.35 per month, and the current free trial balance is $111.05, I've almost spent $300, and I'm about to move back to a self-managed host.