Skip to content

Commit

Permalink
automated commit
Browse files Browse the repository at this point in the history
Signed-off-by: Public copy <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Nov 4, 2024
1 parent 965bbe3 commit f5080ee
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
37 changes: 23 additions & 14 deletions images/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<!--overview:start-->
# Chainguard Image for postgres

Minimal PostgreSQL image.
Minimal image for PostgreSQL, an advanced object-relational database management system.

Chainguard Images are regularly-updated, minimal container images with low-to-zero CVEs.
<!--overview:end-->
Expand All @@ -32,37 +32,43 @@ Be sure to replace the `ORGANIZATION` placeholder with the name used for your or
<!--getting:end-->

<!--body:start-->
## Usage
## Compatibility Notes

The only mandatory environment variable needed by the PostgreSQL Image is `POSTGRES_PASSWORD`.
The Chainguard PostgreSQL Image is comparable to the [official PostgreSQL Image from Docker Hub](https://hub.docker.com/_/postgres). However, the Chainguard image does not run as the root user and contains only the minimum set of tools and dependencies needed to function; for example, it does not include a package manager. Unlike many other Chainguard images, though, the PostgreSQL image does include a shell, allowing you to manage databases interactively.

## Getting Started

This section provides a high-level overview of how you can use Chainguard's PostgreSQL image. For a more in-depth walkthrough of how you can use the image in practice, please refer to our guide on [getting started with the PostgreSQL Chainguard Image](https://edu.chainguard.dev/chainguard/chainguard-images/getting-started/getting-started-postgres/). 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.

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

```sh
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.
Note that the only mandatory environment variable needed by the PostgreSQL Image is `POSTGRES_PASSWORD`.

To persist PostgreSQL data you can mount a volume mapped to the data folder:
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 container's data folder:

```sh
docker run --rm -v $PWD/data:/var/lib/postgresql/data -e POSTGRES_PASSWORD=password -ti --name postgres-test cgr.dev/chainguard/postgres:latest
docker run --rm -d -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:
This command includes the `-d` flag, which causes the container to run in the background and keeps it from taking over your terminal like the previous example.

Following that you can `exec` into the running container:

```sh
docker exec -ti postgres-test bash
```

Connect using the postgres user:
Then switch to using the `postgres` user:

```sh
su postgres
```

Use the `createdb` wrapper to create a test database:
As the `postgres` user, run the `createdb` wrapper to create a test database:

```sh
createdb test
Expand All @@ -87,14 +93,14 @@ CREATE TABLE accounts (
);
```

You could then insert data into the table:
With the table created you can then insert data into it:

```sh
INSERT INTO accounts (username, password, email, created_on, last_login)
VALUES (
'Inky',
'Linky',
'p@$$w0rD',
'inky@example.com',
'linky@example.com',
'2017-07-23',
'2017-07-23'
);
Expand All @@ -113,9 +119,12 @@ You can also use all of PostgreSQL's internal meta-commands. For example, `\dt`
(1 row)
```

## Further Reading

Please refer to our guide on [getting started with the PostgreSQL Chainguard Image](https://edu.chainguard.dev/chainguard/chainguard-images/getting-started/getting-started-postgres/) 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.
## Documentation and Resources

* [Getting Started with the PostgreSQL Chainguard Image](https://edu.chainguard.dev/chainguard/chainguard-images/getting-started/postgres/)
* [Vulnerability Comparison: postgres](https://edu.chainguard.dev/chainguard/chainguard-images/vuln-comparison/postgres/)
* [Blog: How to Use the Postgres Docker Official Image](https://www.docker.com/blog/how-to-use-the-postgres-docker-official-image/)
<!--body:end-->

## Contact Support
Expand Down
3 changes: 2 additions & 1 deletion images/postgres/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ image: cgr.dev/chainguard/postgres
logo: https://storage.googleapis.com/chainguard-academy/logos/postgres.svg
endoflife: ""
console_summary: ""
short_description: Minimal PostgreSQL image.
short_description: Minimal image for PostgreSQL, an advanced object-relational database management system.
compatibility_notes: ""
readme_file: README.md
upstream_url: https://www.postgresql.org/
keywords:
- application
- ai
- featured
tier: APPLICATION
aliases:
- postgres:latest

0 comments on commit f5080ee

Please sign in to comment.