I am attempting to set the hostname inside a docker container during the build since certain software installs use the discovered randomly generated hostname and permanently
You can use docker-compose to build your image and assign the hostname, e.g.
version: '3' services: all: image: testimage container_name: myname hostname: myhost build: context: .
The run as: docker-compose --build up.
docker-compose --build up