4

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 ?

Tnx

Andrey

tgogos
  • 23,218
  • 20
  • 96
  • 128
Andrew Ramnikov
  • 783
  • 2
  • 9
  • 30

1 Answers1

6

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
stas.yaranov
  • 1,797
  • 10
  • 17
  • tnx for the fest answer. Every time i running your command i get this error: osm2pgsql SVN version 0.85.0 (64bit id space) Error: Connection to database failed: could not translate host name "66864b18bb58" to address: Name or service not known – Andrew Ramnikov Nov 20 '15 at 13:49
  • Hi Stas, i changed it like u showed but steel the same error coming back. – Andrew Ramnikov Nov 20 '15 at 14:06
  • What do you write in place of `dockerIP`? There should be an IP-address of machine which is within your docker image. – stas.yaranov Nov 20 '15 at 14:06