DirectorySecurity advisories
Sign in

Directory

postgres-fips logoFIPS

postgres-fips

Last changed
Sign in for updates

Get notified of upcoming product changes, critical vulnerability notifications and patches and more.

Sign in
Versions
Overview
Provenance
Specifications
SBOM
Vulnerabilities
Advisories

Minimal PostgreSQL image.

Download this Image

The image is available on cgr.dev:

docker pull cgr.dev/chainguard/postgres:latest

Usage

The only mandatory environment variable needed by the PostgreSQL Image is POSTGRES_PASSWORD.

You can test the PostgreSQL Image by running the following command:

docker run --rm -e POSTGRES_PASSWORD=password -ti --name postgres-test cgr.dev/chainguard/postgres:latest

This command will run the Image, but no data within the PostgreSQL database will persist after the Image stops running.

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:

docker exec -ti postgres-test bash

Connect using the postgres user:

su postgres

Use the createdb wrapper to create a test database:

createdb test

Then use the PostgreSQL client to Connect to the new database:

psql test

From there you can interact with the database as you would with any other PostgreSQL database. For instance, you can create a sample 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
);

You could then insert data into the table:

INSERT INTO accounts (username, password, email, created_on, last_login)
VALUES (
'Inky',
'p@$$w0rD',
'inky@example.com',
'2017-07-23',
'2017-07-23'
);

You can also use all of PostgreSQL's internal meta-commands. For example, \dt will list all the tables stored within the database:

\dt
          List of relations
 Schema |   Name   | Type  |  Owner
--------+----------+-------+----------
 public | accounts | table | postgres
(1 row)

Further Reading

Please refer to our guide on getting started with the PostgreSQL Chainguard Image for an in-depth walk-through of how you can use the PostgreSQL Image in practice. This getting started guide outlines how to set up and run a PHP application that stores its data in a PostgreSQL database running within a containerized environment.

Licenses

Chainguard Images contain software packages that are direct or transitive dependencies. The following licenses were found in the "latest" version of this image:

  • Apache-2.0

  • BSD-1-Clause

  • BSD-3-Clause

  • BSD-4-Clause-UC

  • CC-PDDC

  • GCC-exception-3.1

  • GPL-1.0-only

View more

For a complete list of licenses, please refer to this Image's SBOM.

Software license agreement

Compliance

This is a FIPS validated image for FedRAMP compliance.

This image is STIG hardened and scanned against the DISA General Purpose Operating System SRG with reports available.

Learn more about STIGsGet started with STIGs

Related images

Category
FIPS
STIG
application
databases

Products

Chainguard Images

© 2024 Chainguard, Inc.