Getting Docker ID in Flask Application Getting Docker ID in Flask Application flask flask

Getting Docker ID in Flask Application


The hostname in the docker container is a short hash of its id. In turn you can use this to get the hostname in Python/Flask:

import socketdocker_short_id = socket.gethostname()