Reputation: 31
When using Ubuntu in docker , there is no way to modify the hostname; each time to connect to ubuntu, hostname is a random string ....
Upvotes: 3
Views: 3609
Reputation: 10447
If you are running the container using docker run
, then you can use -h
option as said by @callmemath
docker run -h custom.hostname -ti ubuntu bash
If you are running containers using docker-compose then you need to use hostname.
hostname: Any_name_you_like
Upvotes: 4
Reputation: 8461
Use -h
option :
docker run -h custom.hostname -ti ubuntu bash
root@custom:/# hostname
custom.hostname
See docker run documentation for more details
Upvotes: 2