We all know how to name a Docker container using the –Name switch, but how do you name the actual container hostname? This post will show you how to do that.
Some applications require hostnames of containers to be consistent or specific for applications to work or for business processes to work correctly.
Luckily, Docker CLI has a solution to that, as you will see in the code below.
The following example. Creates a docker container and set the container’s hostname to host1.
docker run -it -h host1 ubuntu /bin/bash
Leave a Reply