nginx - How can I see a dynamically assigned port from within a docker container? -
i have server application takes few minutes startup , ready process requests. want have container register nginx load-balancer when knows has started, don't know how determine port docker assigned container (i'm starting lots of these docker run -p). ideas?
thanks,
ian
you cannot talk docker daemon default inside container , shouldn't try to. containers perspective, running process on port 80 or whatever default of webapp.
to determine port assigned container, can either use docker port or docker inspect command host running container.
docker port my_webapp_1 returns list of mapped ports of container.
docker inspect my_webapp_1
this returns json in can find networksettings lists ports of containers , ports of host mapped to.
you can run additional process reads data docker port or docker inspect , updates nginx config.
Comments
Post a Comment