• How docker generates container's names

    2 min read

    docker names

    Everytime you create a container using docker, if not already set using --name, docker chooses a name for you: you can expect two words with a underscore:

    $ docker run --rm -d alpine sleep 24h
    38c4cc4e87762fc113ef174e9a4989e13d21037678abd3fe73840b825f14c7bf
    $ docker ps
    CONTAINER ID   IMAGE                          COMMAND                  CREATED         STATUS                PORTS                    NAMES
    38c4cc4e8776   alpine                         "sleep 24h"              5 seconds ago   Up 3 seconds                                   romantic_shtern
    

    For this example it was chosen romantic_shtern, but it can use a great variety of words:

    $ docker ps --all | grep -v "Up" | awk '{ print $NF }'
    NAMES
    mystifying_poitras
    suspicious_shtern
    focused_chatelet
    keen_mendel
    happy_jackson
    xenodochial_margulis
    kind_blackburn
    gallant_pascal
    trusting_thompson
    (...)
    

    So, how does Docker generate names for it's containers?

    01/08/2022

    Read more...

From pet to cattle
Treat your kubernetes clusters like cattle, not pets