docker run -d --name db -e POSTGRES_PASSWORD=devpass -e POSTGRES_DB=app postgres:16

Category: Docker

docker run -d --name db -e POSTGRES_PASSWORD=devpass -e POSTGRES_DB=app postgres:16

Run a PostgreSQL container with env config

Starts PostgreSQL 16, using the POSTGRES_PASSWORD and POSTGRES_DB variables for the initial setup. The container initializes a data directory on first run. Persist data with a volume such as -v pgdata:/var/lib/postgresql/data.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.