DEV Community

Prashant Lakhera
Prashant Lakhera

Posted on

🐳 How do Docker containers Get Those Funny Names?🐳

Image description

🤔 Have you ever wondered how Docker containers get those funny names like determined_buck, objective_wilbur, or relaxed_babbage?
> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
624ba950c764 ubuntu "bash" 26 hours ago Up 26 hours determined_buck
96b8efab5b66 ubuntu "bash" 26 hours ago Exited (0) 26 hours ago objective_wilbur
c07a3eb9a66d ubuntu "bash" 26 hours ago Exited (0) 26 hours ago relaxed_babbage

By default, if you do not specify a name for your container when running it, Docker will assign a humorous or funny name to it using a combination of two randomly chosen words from a predefined list.

🙋‍♀️ Now, the question arises: where is this predefined list defined?
The predefined list of words Docker uses to generate random container names is part of the Docker source code. Docker uses the "moby" project (formerly known as Docker) for its open-source development, and the list of words can be found in the GitHub repository for the moby project.
You can find the list of words in the following file within the moby repository.

💪 So, how does this entire thing work?
So, if we take the example of determined_buck, Docker combines these words. It randomly selects one word from the left list and another from the right list to form the funny container name. For example, determined_buck combines determined from the left list and buck from the right list. The process ensures that you get funny and memorable names for your containers, adding a touch of humor to the world of containerization.

💡 If you want to assign a specific name to your container, you can use the - name flag when running the container:
docker run - name container_name <image name>

Image description

📚 If you're interested in more in-depth explanation of these topics, please check out my new book "Cracking the DevOps Interview"
https://pratimuniyal.gumroad.com/l/cracking-the-devops-interview

Top comments (0)