Skip to content

Commit 25dd48f

Browse files
authored
Update pg_tde docker topic with proper parameters based on user feedback (#802)
* updated docker updated with up to date information for pg_tde encryption parameters, also, cleaned the document a bit, added a paragraph recommending the user to see the pg_tde docs, added a note bolding the fact that we do not recommend using a local keyring file and we suggest using an external KMS. * small fix fixed name of step 5 and a small link fix * Update docker.md updated parameters with correct ones and also removed $ signs so users can actually copy paste the commands properly in cli
1 parent 6c26a5b commit 25dd48f

File tree

1 file changed

+33
-37
lines changed

1 file changed

+33
-37
lines changed

docs/docker.md

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Docker images of Percona Distribution for PostgreSQL are hosted publicly on [Doc
44

55
For more information about using Docker, see the [Docker Docs :octicons-link-external-16:](https://docs.docker.com/).
66

7-
!!! note ""
7+
!!! note
88

99
Make sure that you are using [the latest version of Docker :octicons-link-external-16:](https://docs.docker.com/get-docker/). The ones provided via `apt` and `yum` may be outdated and cause errors.
1010

@@ -34,94 +34,90 @@ For more information about using Docker, see the [Docker Docs :octicons-link-ext
3434
1. Start a Percona Distribution for PostgreSQL container as follows:
3535

3636
```{.bash data-prompt="$"}
37-
$ docker run --name container-name -e POSTGRES_PASSWORD=secret -d percona/percona-distribution-postgresql:{{dockertag}}
38-
```
37+
docker run --name container-name -e POSTGRES_PASSWORD=secret -d percona/percona-distribution-postgresql:{{dockertag}}
38+
```
3939

40-
Where:
40+
Where:
4141

4242
* `container-name` is the name you assign to your container
4343
* `POSTGRES_PASSWORD` is the superuser password
44-
* `{{dockertag}}` is the tag specifying the version you need. Docker identifies the architecture (x86_64 or ARM64) and pulls the respective image. See the [full list of tags :octicons-link-external-16:](https://hub.docker.com/r/percona/percona-distribution-postgresql/tags/).
45-
44+
* `{{dockertag}}` is the tag specifying the version you need. Docker identifies the architecture (x86_64 or ARM64) and pulls the respective image. See the [full list of tags :octicons-link-external-16:](https://hub.docker.com/r/percona/percona-distribution-postgresql/tags/).
4645

47-
!!! tip
46+
!!! tip
4847

4948
You can secure the password by exporting it to the environment file and using that to start the container.
5049

5150
1. Export the password to the environment file:
5251

5352
```{.bash data-prompt="$"}
54-
$ echo "POSTGRES_PASSWORD=secret" > .my-pg.env
53+
echo "POSTGRES_PASSWORD=secret" > .my-pg.env
5554
```
5655

5756
2. Start the container:
5857

5958
```{.bash data-prompt="$"}
60-
$ docker run --name container-name --env-file ./.my-pg.env -d percona/percona-distribution-postgresql:{{dockertag}}
59+
docker run --name container-name --env-file ./.my-pg.env -d percona/percona-distribution-postgresql:{{dockertag}}
6160
```
6261

63-
2. Connect to the container's interactive terminal:
62+
2. Connect to the container's interactive terminal:
6463
6564
```{.bash data-prompt="$"}
66-
$ docker exec -it container-name bash
65+
docker exec -it container-name bash
6766
```
6867
6968
The `container-name` is the name of the container that you started in the previous step.
7069
71-
7270
## Connect to Percona Distribution for PostgreSQL from an application in another Docker container
7371
7472
This image exposes the standard PostgreSQL port (`5432`), so container linking makes the instance available to other containers. Start other containers like this in order to link it to the Percona Distribution for PostgreSQL container:
7573
7674
```{.bash data-prompt="$"}
77-
$ docker run --name app-container-name --network container:container-name -d app-that-uses-postgresql
75+
docker run --name app-container-name --network container:container-name -d app-that-uses-postgresql
7876
```
7977
8078
where:
8179
82-
* `app-container-name` is the name of the container where your application is running,
83-
* `container name` is the name of your Percona Distribution for PostgreSQL container, and
80+
* `app-container-name` is the name of the container where your application is running,
81+
* `container name` is the name of your Percona Distribution for PostgreSQL container, and
8482
* `app-that-uses-postgresql` is the name of your PostgreSQL client.
8583
8684
## Connect to Percona Distribution for PostgreSQL from the `psql` command line client
8785
8886
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:
8987
9088
```{.bash data-prompt="$"}
91-
$ docker run -it --network container:db-container-name --name container-name percona/percona-distribution-postgresql:{{dockertag}} psql -h address -U postgres
89+
docker run -it --network container:db-container-name --name container-name percona/percona-distribution-postgresql:{{dockertag}} psql -h address -U postgres
9290
```
9391
9492
Where:
9593
9694
* `db-container-name` is the name of your database container
9795
* `container-name` is the name of your container that you will use to connect to the database container using the `psql` command line client
98-
* `{{dockertag}}` is the tag specifying the version you need. Docker identifies the architecture (x86_64 or ARM64) and pulls the respective image.
99-
* `address` is the network address where your database container is running. Use 127.0.0.1, if the database container is running on the local machine/host.
96+
* `{{dockertag}}` is the tag specifying the version you need. Docker identifies the architecture (x86_64 or ARM64) and pulls the respective image.
97+
* `address` is the network address where your database container is running. Use 127.0.0.1, if the database container is running on the local machine/host.
10098
10199
## Enable encryption
102100
103-
Percona Distribution for PostgreSQL Docker image includes the `pg_tde` extension to provide data encryption. You must explicitly enable it when you start the container.
101+
Percona Distribution for PostgreSQL Docker image includes the `pg_tde` extension to provide data encryption. You must explicitly enable it when you start the container. For more information, see the [pg_tde documentation](https://docs.percona.com/pg-tde/index.html).
104102
105-
Here's how to do this:
106-
{.power-number}
103+
Follow these steps to enable `pg_tde`:
107104
108105
1. Start the container with the `ENABLE_PG_TDE=1` environment variable:
109106
110107
```{.bash data-prompt="$"}
111-
$ docker run --name container-name -e ENABLE_PG_TDE=1 -e POSTGRES_PASSWORD=sUpers3cRet -d percona/percona-distribution-postgresql:{{dockertag}}
108+
docker run --name container-name -e ENABLE_PG_TDE=1 -e POSTGRES_PASSWORD=sUpers3cRet -d percona/percona-distribution-postgresql:{{dockertag}}
112109
```
113110
114111
where:
115-
112+
116113
* `container-name` is the name you assign to your container
117114
* `ENABLE_PG_TDE=1` adds the `pg_tde` to the `shared_preload_libraries` and enables the custom storage manager
118-
* `POSTGRES_PASSWORD` is the superuser password
119-
115+
* `POSTGRES_PASSWORD` is the superuser password
120116
121117
2. Connect to the container and start the interactive `psql` session:
122118
123119
```{.bash data-prompt="$"}
124-
$ docker exec -it container-name psql
120+
docker exec -it container-name psql
125121
```
126122
127123
??? example "Sample output"
@@ -139,23 +135,24 @@ Here's how to do this:
139135
CREATE EXTENSION pg_tde;
140136
```
141137
142-
4. Configure a key provider. In this sample configuration intended for testing and development purpose, we use a local keyring provider.
138+
4. Configure a key provider with a keyring file. This setup is intended for development and stores the keys unencrypted in the specified data file. The below sample configuration is intended for testing and development purposes.
143139
144-
For production use, set up an external key management store and configure an external key provider. Refer to the [Setup :octicons-link-external-16:](https://docs.percona.com/pg-tde/setup.html#key-provider-configuration) chapter in the `pg_tde` documentation.
140+
!!! note
141+
For production use, we **strongly recommend** setting up an external key management store and configure an external key provider. Refer to the [Setup :octicons-link-external-16:](https://docs.percona.com/pg-tde/setup.html#key-provider-configuration) topic in the `pg_tde` documentation.
145142
146143
<i warning>:material-information: Warning:</i> This example is for testing purposes only:
147144
148145
```sql
149-
SELECT pg_tde_add_key_provider_file('file-keyring','/tmp/pg_tde_test_local_keyring.per');
146+
SELECT pg_tde_add_database_key_provider_file('file-vault', '/tmp/pg_tde_test_001_basic.per');
150147
```
151148
152-
5. Add a principal key
149+
5. Set the principal key:
153150
154151
```sql
155-
SELECT pg_tde_set_principal_key('test-db-master-key','file-keyring');
152+
SELECT pg_tde_set_key_using_database_key_provider('test-db-key', 'file-vault');
156153
```
157154
158-
The key is autogenerated. You are ready to use data encryption.
155+
The key is auto-generated. You are ready to use data encryption.
159156
160157
6. Create a table with encryption enabled. Pass the `USING tde_heap` clause to the `CREATE TABLE` command:
161158
@@ -167,7 +164,7 @@ Here's how to do this:
167164
168165
To enable the `pg_stat_monitor` extension after launching the container, do the following:
169166
170-
* connect to the server,
167+
* connect to the server,
171168
* select the desired database and enable the `pg_stat_monitor` view for that database:
172169
173170
```sql
@@ -180,7 +177,7 @@ To enable the `pg_stat_monitor` extension after launching the container, do the
180177
\d pg_stat_monitor;
181178
```
182179
183-
??? example "Output"
180+
??? example "Output"
184181
185182
```
186183
View "public.pg_stat_monitor"
@@ -228,6 +225,5 @@ To enable the `pg_stat_monitor` extension after launching the container, do the
228225
wait_event_type | text | | |
229226
```
230227
231-
Note that the `pg_stat_monitor` view is available only for the databases where you enabled it. If you create a new database, make sure to create the view for it to see its statistics data.
232-
233-
228+
!!! note
229+
The `pg_stat_monitor` view is available only for the databases where you enabled it. If you create a new database, make sure to create the view for it to see its statistics data.

0 commit comments

Comments
 (0)