Is it possible to set a container’s hostname to the hostmachine’s hostname or perhaps container name (the one docker assigns not a custom one)?
I want to set it though compose file (hostname: ) or docker run but using the container name (the dynamic one docker assigns PROJECT_SERVICENAME_X) or set it to the host machine hostname… again dynamically not hardcoded. Think in a swarm network for example. Is there a Docker specific environment variable or something similar?
I know I can do that but I don’t want to hardcode anything. I want to set it either to the host machine’s hostname or docker’s automatic naming. For example docker does this:{PROJECT_NAME}_{SERVICE_NAME}_{CONSECUTIVE_NUMBER}