FreeKB - Docker docker run -h or --hostname command
Docker - docker run -h or --hostname command

When creating a container using the docker run command, the -h or --hostname option can be used to define the hostname of the container. 

In this example, a container is created using the foo:latest image, and the hostname of the container will be foo.example.com.

docker run --hostname foo.example.com foo:latest

 

The docker container ls command can be used to ensure the container is up and running.

~]# docker container ls
CONTAINER ID     IMAGE              COMMAND                 CREATED         STATUS     PORTS     NAMES
d937372c09ab9    b939aa938add9913   "/docker-entrypoin..."  6 minutes ago   Up 6 minutes         foo

 

The docker exec command can be used to ensure the container has the hostname you declared.

~]# docker exec foo hostname
foo.example.com

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 9faac in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |