There is no API available (as of Docker Remote API v1.11) to get the Docker hostname programmatically from within the container.
You can explicitly set the container's hostname when you run the container, docker run --hostname=
, or you could set an environment variable with the Docker hostname at runtime and pass that value in your logs (docker --env=
).