Docker Community Forums

Share and learn in the Docker community.

Create an image and a container with kartoza/postgis


(Dockergi) #1

I need to use this Docker Hub image:
https://hub.docker.com/r/kartoza/postgis/
to have the PostgreSQL database and its PostGIS plugin available on my PC.
Below you will find all the input and output code.
I need PostgreSQL because I’m doing a java course and I have to learn how to use JDBC.
Thank you so much

Code:

1) DOCKERFILE:

FROM kartoza/postgis:9.6-2.4
LABEL Author=“Nome Cognome”
EXPOSE 5432
VOLUME create pg_data

2) CLI:

docker build -t postgresql-postgis-eb:9.6-2.4 .
docker run --name=postgis -d -e POSTGRES_USER=eb -e POSTGRES_PASS=password -e POSTGRES_DBNAME=gis -e ALLOW_IP_RANGE=0.0.0.0/0 -p 5432:5432 -v pg_data:/var/lib/postgresql --restart=always postgresql-postgis-eb:9.6-2.4

3) BROWSER:
http://192.168.99.103:5432/

4) I READ IN THE BROWSER:

The page does not work 192.168.99.103 has not sent data.
ERR_EMPTY_RESPONSE

5) WINDOWS PROMPT:
https://paste.ubuntu.com/p/2JySyrZfQY/

Docker version: 18.09.3
Windows version: Windows 10 Pro Ita 64 bit updated to 15 April 2019


(Dockergi) #2

I installed SQuirreL SQL Client and created an X table. I spend Docker then I reopened the program and I found table X. I think everything is working properly.
I would like to know if with Docker it is possible to do these 2 things:
1.Import a database into the Docker volume;
2.Export a database contained in Docker into Windows (pg_data:/var/lib/postgresql).
What codes should I use?