Background
When you start a Docker container as in the following example:
$ docker run -ti ubuntu:latest
Docker docker automatically assigns the container an ID and a friendly name.
Docker friendly names are of the format adjective_famousPerson
.
Problem
I would like to get the friendly name that Docker will generate for the next container, so that I can assign that name to the hostname parameter of my docker run
command.
For example:
$ docker run -ti --hostname docker.next_friendly_name ubuntu:latest
Question
Is there a built in way to do this with docker?
I need a friendly name that is randomly generated, but I don't want to script it up myself if there is a way to do this with Docker or even Docker Swarm or Kubernetes.
Additionally, the name
of the container and the hostname
of the container need to match.
--name
is not sufficient?hostname
command from inside the container to match for analytics and logging purposes. So my question is referring to both inside and outside of the container.