Docker PostgreSQL data encryption at rest

Viewed 1450

According to the manual, PostgreSQL supports 'Data Partition Encryption' in order to store the data encrypted at rest on the system.

For my next application I want to containerize PostgreSQL using Docker. Unfortunately I have not found any option, to encrypt the database files within this Docker container to protect the data. I thought about something like entering a password when the container is starting to decrypt all the needed files at runtime.

Has anyone experience with this?

1 Answers

"Data Partition Encryption" means that you are off-loading the encryption to the OS, and would provide the key at the time of mounting the disk partition that the data directory is read from.

In the context of docker, you would generally achieve this by encrypting the partition that you either:

  • bind mount the data directory from
  • store docker volumes in

Eg: by default docker volumes are stored in /var/lib/docker/volume on Linux - therefore if that directory is on a partition that is encrypted using LUKS or similar then you have already implemented your goal.

In general I'd recommend always using full disk encryption for local machines, and taking advantage of similar features on cloud platforms like AWS.

Related