You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update command to connect to PG database in README (#240)
* Update command to connect to PG database in README
Use `docker exec` on the running container rather than booting up another postgres container to connect to the database
* Provide different options for connecting to the database
Copy file name to clipboardExpand all lines: README.md
+15-4Lines changed: 15 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,10 +21,21 @@ In order to run a basic container capable of serving a PostGIS-enabled database,
21
21
22
22
For more detailed instructions about how to start and control your Postgres container, see the documentation for the `postgres` image [here](https://registry.hub.docker.com/_/postgres/).
23
23
24
-
Once you have started a database container, you can then connect to the database as follows:
25
-
26
-
docker run -it --link some-postgis:postgres --rm postgres \
27
-
sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'
24
+
Once you have started a database container, you can then connect to the database either directly on the running container:
25
+
26
+
docker exec -ti some-postgis psql -U postgres
27
+
28
+
... or starting a new container to run as a client. In this case you can use a user-defined network to link both containers:
29
+
30
+
docker network create some-network
31
+
32
+
# Server container
33
+
docker run --name some-postgis --network some-network -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis
Check the documentation on the [`postgres` image](https://registry.hub.docker.com/_/postgres/) and [Docker networking](https://docs.docker.com/network/) for more details and alternatives on connecting different containers.
28
39
29
40
See [the PostGIS documentation](http://postgis.net/docs/postgis_installation.html#create_new_db_extensions) for more details on your options for creating and using a spatially-enabled database.
0 commit comments