Docker - Speed Test inside a container

Performing a speed test inside a Docker container can be useful for diagnosing network performance issues, checking bandwidth usage, or evaluating the container's network connectivity. This guide will walk you through the process of setting up and running a speed test using the speedtest-cli utility. 


Requirements

  • Docker installed and running on the host machine.
  • A functioning docker container with network access.
  • Terminal or Command Line admin access.


Steps

Launch a Docker container with network access in order. 


  • The first command downloads a docker image from the Docker registry. Python is the name of the image, followed by its version.
docker pull python:3.9-slim
  • This command runs the container using the python image. It automatically will put you in the container so you can install and run the speedtest.
docker run -it --name speedtest-container python:3.9-slim /bin/bash
  • Install the speed test utility
pip install speedtest-cli
  • Run the speed test, which will provide you the analytic data you should provide to the support team.
speedtest-cli
Unable to run Speed Test?
Please ensure you are able to perform ping google.com while inside the container. If you're not receiving successful connection messages, you may need to troubleshoot the connectivity access further or add the --network host flag inside the container.

Additionally, you can use docker network ls to check to see if the container has access to the correct network.

What is --network host?
This forces the programs running inside of a docker container (speedtest) to run on the host itself. It allows the container greater access than normal.

How do I exit the container?
Type exit or CTRL+D

Are there alternatives to speedtest? It doesn't seem to be working.
Yes, you can perform the same steps with other utilities, such as fast-cli. There are many out there.



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article