Using Docker network and the extra_hosts property
When you're running a Docker container on a different network than the standard one (called bridge
) and you wish to run a second container that needs to access the first container, you need to run the second container on the same network.
Let's say, you're running a MySQL database on a network called my_network
and you wish to be able start a second container like phpMyAdmin and get access to the database, then you need to use the --network
CLI option when running the second container using docker run
.
Now, imagine the first container is a web application and the second container should be able to access his web page and, too, reusing the same alias?