As the title says. I need to be able to retrieve the IP address the docker hosts and the portmaps from the host to the container, and doing that inside of the container.
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
If you are running a Windows container on a Service Fabric cluster, the host's IP address is available via the environment variable
Fabric_NodeIPOrFQDN
. Service Fabric environment variablesHere is another option for those running Docker in AWS. This option avoids having using apk to add the curl package and saves the precious 7mb of space. Use the built-in wget (part of the monolithic BusyBox binary):
Here is how I do it. In this case, it adds a hosts entry into /etc/hosts within the docker image pointing taurus-host to my local machine IP: :
Then, from within Docker container, script can use host name taurus-host to get out to my local machine which hosts the docker container.
As @MichaelNeale noticed, there is no sense to use this method in
Dockerfile
(except when we need this IP during build time only), because this IP will be hardcoded during build time.Maybe the container I've created is useful as well https://github.com/qoomon/docker-host
You can simply use container name dns to access host system e.g. curl http://dockerhost:9200, so no need to hassle with any IP address.
In linux you can run
In macOS your host machine is not the Docker host. Docker will install it's host OS in VirtualBox.