I have a docker container running uhttpd and serving a static HTML page. How can I dynamically insert the hostname of the container into the static HTML page? I want to keep the container as lightweight as possible.
Display hostname in static HTML page on uhttpd
webserver;html;docker;uhttpd
Why not just have a command that runs as part of the container's startup that generates the static HTML page with the hostname within it.$ cat <<EOF > /path/to/var/www/hostname.html<html><body><p>hostname is: $(hostname)</p></body></html>EOFThis command can be placed in /etc/rc.d/rc.local assuming you're using a SysV style of startup scripts. If you're using systemd you can also do the same, but you'll need to enable the service:$ sudo service rc-local startThis will mark it to run, to make it run per startup:$ sudo systemctl enable rc-localIf you're using something else, such as Upstart, there are equivalent methods for doing the same things above.References[Solved] systemd services to replace /etc/rc.local{,.shutdown}