How does Docker generate default container names?

Today I was wondering about Docker default container names. They’re cool enough to have caught my attention during the first hour of playing with Docker. furious_heisenberg, agitated_darwin, romantic_curie… who would come up with something like that?

Docker default container names

When you create a new Docker container and don’t give a custom name (by passing --name <name> on the CLI) Docker generates a name for you. For all commands you later run that interact with the container you can either use its hash ID or its name. So yes, the name is quite important.

Docker default container names
Docker default container names

How does Docker do that?

Of course I wanted to know how Docker generates default container names. I found the code in their GitHub repository – and learned that they use Go! In fact, over 90% of the Docker code is written in Go. And look at this gem towards the end of the generator.

if name == "boring_wozniak" /* Steve Wozniak is not boring */ {
  goto begin

But what good is a cool name generator if it’s not publicly available on the Internet as a service these days? So, here it is:

9 thoughts on “How does Docker generate default container names?

  1. I came across your site trying to figure out why Docker landed on this convention of generating semi-random names. Where did this idea come from?

Leave a Reply