Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/docker/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ where:
* `container name` is the name of your Percona Distribution for PostgreSQL container, and
* `app-that-uses-postgresql` is the name of your PostgreSQL client.

!!! tip

To connect from an application running on the host machine itself, start the database container with the `-p` option (`-p host-port:container-port`):

```{.bash data-prompt="$"}
docker run --name container-name -e POSTGRES_PASSWORD=secret -p 127.0.0.1:5432:5432 -d percona/percona-distribution-postgresql:{{dockertag}}
```

Then, from your application, connect to `localhost` on the host port, for example `localhost:5432`.

If port 5432 is already in use on the host machine, specify a different host port, for example `-p 127.0.0.1:5433:5432`, and connect to `localhost:5433`.

!!! note

Binding the port to `127.0.0.1` keeps the database unreachable from other machines on the network.

## Connect to Percona Distribution for PostgreSQL from the `psql` command line client

The following command starts another container instance and runs the `psql` command line client against your original container, allowing you to execute SQL statements against your database:
Expand Down
Loading