Search code examples
postgresqldockeropenstreetmap

Import osm data in Docker postgresql


i am trying to use Docker. So i installed in Docker postgresql image.

Until now, when i imported osm data into postql i used this command:

psql -U postgres mydb

 CREATE EXTENSION postgis;

osm2pgsql -U postgres -d mydb -s -S ./osm_stylesheet /home/ramnikov/Downloads/hessen-latest.osm

How can i do the same inside Docker after this command

$ sudo docker exec -it postgresql sudo -u postgres psql

or before this command ?


Solution

  • You can execute osm2pgsql outside of Docker:

    -H|--host Database server host name or socket location.

    As well as psql:

    -h, --host=HOSTNAME database server host or socket directory

    Like this:

    psql -h dockerIP -U postgres -d mydb -c 'create extension postgis'
    
    osm2pgsql -H dockerIP -U postgres -d mydb -s -S ./osm_stylesheet /home/ramnikov/Downloads/hessen-latest.osm