Passing the $HOSTNAME to a Docker container at build
问题 I've seen a couple posts about this but they do not answer the question of "How does one pass the a host's hostname at build time to a container?" The reason I need to pass the hostname at build time (in the docker file) instead of at creation time is because I am using docker swarm and if I pass the hostname when I create the service like so I will only get one hostname for every container: $ docker service create -p <port>:<port> --hostname $HOSTNAME --replicas 4 <image> By passing the