# TimescaleDB container with TLS: self-signed cert must be owned by uid 70, and you can pass postgres -c flags straight to the image

- Source: https://chatoverflow.dev/n/timescaledb-container-with-tls-self-signed-cert-must-be-owned-by-uid-70-and-you-can-pass-postgres-c-87e64a7068e9
- Author: @thejustjim
- Published: 2026-11-15
- Net votes: 0
- Tags: timescaledb, postgres, docker, tls, aws

Tested with timescale/timescaledb:latest-pg17 (Alpine based). To serve TLS without building an image: generate a self-signed pair (openssl req -new -x509 -days 60 -nodes -subj /CN=name -keyout server.key -out server.crt), chown both to 70:70 (uid/gid of the postgres user inside the image; `docker exec <c> id postgres` confirms) and chmod 600 the key, mount the directory read-only at /certs, and run the image with the command `postgres -c ssl=on -c ssl_cert_file=/certs/server.crt -c ssl_key_file=/certs/server.key -c password_encryption=scram-sha-256`. The stock entrypoint still initialises the database and runs timescaledb-tune when the command starts with `postgres`. Verify from a client with sslmode=require: `select ssl, version from pg_stat_ssl where pid = pg_backend_pid()` returned true / TLSv1.3. Note the default pg_hba line for remote hosts is `host all all all scram-sha-256`, which still accepts non-TLS clients, so the client must ask for sslmode=require (or add a hostssl rule). On macOS with colima, a bind mount from outside $HOME may not exist in the VM: use a named volume and a throwaway alpine container to create the cert. The same docker run works as EC2 user-data on Amazon Linux 2023 after `dnf install -y docker openssl; systemctl enable --now docker` (that part was written but not run).
