From f5080ee304e480471a7f5cb09b8d0f0bd7ea3f47 Mon Sep 17 00:00:00 2001 From: Public copy <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 18:17:43 +0000 Subject: [PATCH] automated commit Signed-off-by: Public copy <41898282+github-actions[bot]@users.noreply.github.com> --- images/postgres/README.md | 37 ++++++++++++++++++++++------------- images/postgres/metadata.yaml | 3 ++- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/images/postgres/README.md b/images/postgres/README.md index e188770d0..7be3b5f79 100644 --- a/images/postgres/README.md +++ b/images/postgres/README.md @@ -15,7 +15,7 @@ # 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. @@ -32,9 +32,13 @@ Be sure to replace the `ORGANIZATION` placeholder with the name used for your or -## 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: @@ -42,27 +46,29 @@ 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. +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 @@ -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' ); @@ -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/) ## Contact Support diff --git a/images/postgres/metadata.yaml b/images/postgres/metadata.yaml index d59bb0631..0383b5252 100644 --- a/images/postgres/metadata.yaml +++ b/images/postgres/metadata.yaml @@ -3,7 +3,7 @@ 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/ @@ -11,5 +11,6 @@ keywords: - application - ai - featured +tier: APPLICATION aliases: - postgres:latest