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


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....

linux,docker

How to execute X client and X Window in Container (docker gui)

Today I will talk to you about X, not iPhone X, nor X-Men, but X Window System, He is the main graphical interface display component of the current Linux system. Since it is very easy to expand and modularize, it has been used since it was established in 1986. The X Window system adopts the Client/Server architecture, which splits the application program and the display into two. The application program of X Windows is usually called X Client, and the display is the well-known X Server. The X client communicates with the X server through the X protocol (X protocol), which is an asynchronous network communication protocol.

docker

Docker antivirus strategy

I just watched Story of Yanxi Palace recently, so I wanted to introduce a MacOS anti-drug strategy. This article teaches you how to use Docker to clean MacOS. Briefly introduce how we use anti-virus software to scan viruses through docker. It is assumed that my current directory is in my home directory, so ${PWD} is the current directory and will be mounted to the scan folder in the container. Therefore, when you use clamscan -r /scan/, you can scan all the files. Adding the -r parameter will use the recursive method to enter the subdirectory layer by layer to scan.