Konubinix' opinionated web of thoughts

Docker

Fleeting

registry

desktop

host.docker.internal

We recommend that you connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host.

https://docs.docker.com/desktop/networking/#:~:text=I%20want%20to%20connect%20from%20a%20container%20to%20a%20service%20on%20the%20host,-The%20host%20has&text=We%20recommend%20that%20you%20connect,using%20gateway.docker.internal%20.

also available not in docker desktop, needing an extra –add-host flag

also available not in docker desktop, needing an extra –add-host flag

also communicate with the host via host.docker.internal. This won’t work automatically, but you need to provide the following run flag:

–add-host=host.docker.internal:host-gateway

https://stackoverflow.com/questions/31324981/how-to-access-host-port-from-docker-container/61424570#61424570

network

custom hosts, defined in /etc/hosts on the host machine, aren’t inherited by containers

isolated from one another

Not only that, but you can’t connect to alpine3 from alpine1 by its IP address either

https://docs.docker.com/network/network-tutorial-standalone/

a container can be connected to several networks, but will resolves dns names only in its starting network

alpine4 is connected to both the default bridge network and alpine-net. It should be able to reach all of the other containers. However, you will need to address alpine3 by its IP address.

https://docs.docker.com/network/network-tutorial-standalone/

custom network

automatic service discovery

On user-defined networks like alpine-net, containers can not only communicate by IP address, but can also resolve a container name to an IP address. This capability is called automatic service discovery.

https://docs.docker.com/network/network-tutorial-standalone/

Automatic service discovery can only resolve custom container names, not default automatically generated container names,

https://docs.docker.com/network/network-tutorial-standalone/

default bridge

not recommended for production

default bridge network is not recommended for production

https://docs.docker.com/network/network-tutorial-standalone/

cannot resolve dns names

try pinging the alpine2 container by container name. This will fail

https://docs.docker.com/network/network-tutorial-standalone/

Networking with standalone containers

Notice that this network’s gateway is 172.18.0.1, as opposed to the default bridge network, whose gateway is 172.17.0.1. The exact IP address may be different on your system.

https://docs.docker.com/network/network-tutorial-standalone/

docker run -dit –name alpine1 –network alpine-net alpine ash

https://docs.docker.com/network/network-tutorial-standalone/

Notes pointant ici