Add Prometheus metrics outside – docker related

My looks like this:

import os
import sys
from prometheus_client import start_http_server, Summary
import random
import time

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
    s = Summary('request_latency_seconds', 'Description of summary')
    s.observe(4.7)    # Observe 4.7 (seconds in this case)
        from import execute_from_command_line
    except ImportError:
        # The above import may fail for some other reason. Ensure that the
        # issue is really that Django is missing to avoid masking other
        # exceptions on Python 2.
            import django
        except ImportError:
            raise ImportError(
                "Couldn't import Django. Are you sure it's installed and "
                "available on your PYTHONPATH environment variable? Did you "
                "forget to activate a virtual environment?"

If I run my django app using docker, I am able to see added Summary metrics. However, if I try to run Django management command, created metric object will be not added to Prometheus.
I am basically trying to add many metrics the same way I did it with Summary, but I dont want my exposed port to be stopped (if I run loop inside, it will stop)… ideally, if I would be able to run management command (I will exec to running container, and run command like "python prometheus"), where I will be able to create objects such as here in, and they will be present in Prometheus. Maybe I will have to attach somehow to exposed port, because outside it does not work.
I am using this api:
But I don’t find


very useful, as docker is already creating its own server.
Thank you, and sorry for confusion

Source: Docker Questions