How to configure docker container Hostname or IP address permanently?
Hi @Kishor
There’s nothing permanent in containers, as they are ephemeral by design.
While starting the container with docker run command, you can provide -h flag to provide a hostname and --ip to set an IP address and --net flag attaches a container to a specific network.
docker run --net mynet123 -h myhostname --ip 172.18.0.22 -it ubuntu bash
Thank you! for the reply @Santosh_KodeKloud
But my application requires a permanent hostname or IP address. How can I achieve this?
Thought about Kubernetes?
What you think about aws ecs?
That would work too.
Either way you need a container orchestration system (like kubernetes, or ECS) that has a “front door”, usually a cloud load balancer which has the permanent address. Routing performed by the container orchestration system sends the request to the correct container., even if it is restarted and replaced by a new container running the same application.