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

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.

certbot,docker,ftp

curlftpfs introduction and manual certificate application

Situation sharing, imagine that you have WebHosting, which only provides FTP connection, and then you want to apply for a certificate manually. In this article, I share how I use Docker to install curlftpfs, mount the FTP folder of the remote host, and then execute certbot in the container to apply for an SSL certificate. Leaving aside the certificate application, when I first discovered the curlftpfs command, I found it very interesting, especially if you are a MacOS user and do not have a satisfactory FTP software at hand. You love scrolling through the command line as much as I do, so maybe you should love this command too. 🤭

docker,container,laravel

Manually update the full record of D-Laravel's user id on Nas

This article fully records how I update the uid of the fpm image on my Nas. In this article, you should learn to query related concepts such as container id and commit container.