postgresqldockerdocker-composeopenmaptiles

How to connect to OpenMapTiles Docker Postgres DB


I am currently playing around with openmaptiles (https://github.com/openmaptiles/openmaptiles) and I'd like to figure out how to import my own data into the resulting mbtiles. But first I'd like to look at how the postgres database it is using is structured. I just can't figure out how I can connect to the postgres database using my GUI tool I have running locally.

I start postgres using the command provided on the help page: docker-compose up -d postgres. Is it just not visible to outside of the docker container (I am also very new to docker)? And is there a way to make it visible to my local system?


Solution

  • docker-compose up -d postgres refers to this part of the docker-compose.yaml file:

    services:
      postgres:
        image: "openmaptiles/postgis:2.9"
        volumes:
        - pgdata:/var/lib/postgresql/data
        networks:
        - postgres_conn
        ports:
         - "5432"
    env_file: .env
    
    ...
    

    As you can see in the ports: section, there is no container - host port mapping here. To access this postgres database from your host try using "5432:5432". (notice that if you're already using this port on the host, you will have to pick an available one).

    For more information on the docker-compose file reference and ports, check the docs.