Skip to content

Latest commit

 

History

History
 
 

postgres

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

postgres

Status stable
OCI Reference cgr.dev/chainguard/postgres

Minimal PostgreSQL image. EXPERIMENTAL

Get It!

The image is available on cgr.dev:

docker pull cgr.dev/chainguard/postgres:latest

Usage

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)