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?


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/

  • 1
    I already have an existing postgis container but created with no port map – Sounchio Serge Apr 20 '18 at 1:02
  • 1
    Docker compose is a good way to manage your containers so that you can add and remove ports simply. That's what I'd recommend you use. – Alex Leith Apr 20 '18 at 4:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.