[GIS] Connecting local QGIS to Docker container

dockerpostgispostgresqlqgis

I have a Docker container from PostgreSQL image installed.

How do I connect my local QGIS app to my PostGIS database to view the map?

Best Answer

First, you need to ensure your Docker container has it's ports exposed, so do something like:

docker run -p 5432:5432 --name some-postgis -e POSTGRES_PASSWORD=mysecretpassword -d mdillon/postgis

And now, depending on your platform, you should be able to connect to it using QGIS by setting the host to localhost, the username to postgres an the password to mysecretpassword. It should be clear how to change the rest.

Notes on Docker usage from here: https://hub.docker.com/r/mdillon/postgis/

Caveat for the old way of running Docker on Windows. If you are using the Virtualbox method of running Docker on Windows, i.e., Docker Machine, you need to get the Docker IP address using docker-machine ip. See: https://docs.docker.com/machine/reference/ip/