Status | stable |
OCI Reference | cgr.dev/chainguard/postgres |
- View Image in Chainguard Academy
- View Image Catalog for a full list of available tags. Contact Chainguard for enterprise support, SLAs, and access to older tags.
Minimal PostgreSQL image. EXPERIMENTAL
The image is available on cgr.dev
:
docker pull cgr.dev/chainguard/postgres:latest
The only mandatory environment variable needed by the PosgreSQL image is POSTGRES_PASSWORD
To test and not persist PostgreSQL data run...
docker run --rm -e POSTGRES_PASSWORD=password -ti --name postgres-test cgr.dev/chainguard/postgres:latest
Alternatively, to persist PostgreSQL data you can mount a volume mapped to the data folder
docker run --rm -v $PWD/data:/var/lib/postgresql/data -e POSTGRES_PASSWORD=password -ti --name postgres-test cgr.dev/chainguard/postgres:latest
In a new terminal exec into the running container and use the PosgreSQL client to create a DB and Table
docker exec -ti postgres-test bash
Connect using the postgres user
su postgres
Create a test DB
createdb test
Connect to the test DB
psql test
Create a table
CREATE TABLE accounts (
user_id serial PRIMARY KEY,
username VARCHAR ( 50 ) UNIQUE NOT NULL,
password VARCHAR ( 50 ) NOT NULL,
email VARCHAR ( 255 ) UNIQUE NOT NULL,
created_on TIMESTAMP NOT NULL,
last_login TIMESTAMP
);
List the tables
\dt
You should see the newly created accounts
table
List of relations
Schema | Name | Type | Owner
--------+----------+-------+----------
public | accounts | table | postgres
(1 row)