Docker and localhost
By default, docker containers are run on a network bridge that is isolated from your host machine’s network stack. That means that your containers will have a slightly different view of the network that your normal applications do. This is most obvious in the case of
127.0.0.1, because the docker network points these to the docker isolation environment, not the host machine as you’re used to.
Docker and EdgeX
docker-compose.yml file provided by EdgeX Foundry runs all of your services inside the the same docker environment, exposing each service’s port on the host machine’s
localhost. This makes it very quick and easy to get the EdgeX stack up and running, but it hides some complexity in docker which you are likely to run into once you start using a more complex setup.
If you are running an EdgeX service outside of Docker, while running the rest of it inside of Docker, you’re going to need to tell those services on the inside where to find the services on the outside. You can use the actual IP address of your host, but this is prone to change if you’re not on a dedicated server. Fortunately, docker provides an easier way.
On Windows or Mac
Docker on Windows (and Mac) creates a virtual network adapter for your containers, but you can’t see it to check it’s IP address. Instead, use the special host name
host.docker.internal in place of
localhost or an IP address.
For Linux you can see the network adapter, called
docker0, which means you can easily check it’s IP address with
ip addr show docker0. Usually the IP address assigned to it will be