This is an old revision of the document!
Docker - Containers - Assign a hostname to the container
The value supplied to the –hostname command is set inside /etc/hostname and /etc/hosts inside the container.
Consequently, it appears in the command prompt.
It plays a role in configuring container DNS and can be helpful while in the learning stages of a multi-container setup.
It is not easy to access from outside the container, but it will appear in the container's log files, and when those files are written to a volume independent of the host, it can make it easier to identify the container.
docker run --hostname=value
or
docker run -h value
While --name and --hostname are both useful for identification of containers, sometimes, it's not about naming the container at all. Rather, it's about having a container clean up after itself without having to remember to do it yourself.