How to reach localhost on host from docker container?

For Docker running on Windows I have used directly host.docker.internal (without the extra_hosts in the docker-compose.yml) to connect to services running on the WIndows-host from inside a Docker-container.

For Docker running on Linux I have used 172.17.0.1 which is the Docker-host in Docker’s default-network. Maybe not the best way - but it is working :slight_smile:



For the other problem (seeding a MongoDB with data) I have done a backup/restore from one mongo-server to another using this command to create a dump on Server A into the directory ./dump/<sourcedatabase>

mongodump --host "<sourcehost>" --username "<sourceuser>" --password "<sourcepassword>" --db "<sourcedatabase>"

and this to restore it to Server B:

mongorestore --host "<destinationhost>" --db "<destinationdatabase>" --username "<destinationuser>" --password "<destinationpassword>" dump/<sourcedatabase>/

Maybe this can be used as a blueprint?

1 Like