{"user":"library","name":"postgres","namespace":"library","repository_type":"image","status":1,"status_description":"active","description":"The PostgreSQL object-relational database system provides reliability and data integrity.","is_private":false,"is_automated":false,"star_count":15024,"pull_count":11666908503,"last_updated":"2026-09-29T01:09:11.01933Z","last_modified":"2026-09-24T21:09:46.530291Z","date_registered":"2014-06-05T20:01:35Z","collaborator_count":0,"affiliation":null,"hub_user":"stackbrew","has_starred":false,"full_description":"**Note:** the description for this image is longer than the Hub length limit of 25000, so has been trimmed.  The full description can be found at [https://github.com/docker-library/docs/tree/master/postgres/README.md](https://github.com/docker-library/docs/tree/master/postgres/README.md).  See also [docker/hub-feedback#238](https://github.com/docker/hub-feedback/issues/238) and [docker/roadmap#475](https://github.com/docker/roadmap/issues/475).\n\n# Quick reference\n\n-\t**Maintained by**:  \n\t[the PostgreSQL Docker Community](https://github.com/docker-library/postgres)\n\n-\t**Where to get help**:  \n\t[the Docker Community Slack](https://dockr.ly/comm-slack), [Server Fault](https://serverfault.com/help/on-topic), [Unix \u0026 Linux](https://unix.stackexchange.com/help/on-topic), or [Stack Overflow](https://stackoverflow.com/help/on-topic)\n\n# Supported tags and respective `Dockerfile` links\n\n-\t[`19beta4`, `19beta4-trixie`](https://github.com/docker-library/postgres/blob/d588a44673ea9d123c1acb1a6924de10a27fc315/19/trixie/Dockerfile)\n\n-\t[`19beta4-bookworm`](https://github.com/docker-library/postgres/blob/d588a44673ea9d123c1acb1a6924de10a27fc315/19/bookworm/Dockerfile)\n\n-\t[`19beta4-alpine3.24`, `19beta4-alpine`](https://github.com/docker-library/postgres/blob/d588a44673ea9d123c1acb1a6924de10a27fc315/19/alpine3.24/Dockerfile)\n\n-\t[`19beta4-alpine3.23`](https://github.com/docker-library/postgres/blob/d588a44673ea9d123c1acb1a6924de10a27fc315/19/alpine3.23/Dockerfile)\n\n-\t[`18.6`, `18`, `latest`, `18.6-trixie`, `18-trixie`, `trixie`](https://github.com/docker-library/postgres/blob/e00e1bd34ec5c8a8e7ad89b273b3d42efaf6d5bc/18/trixie/Dockerfile)\n\n-\t[`18.6-bookworm`, `18-bookworm`, `bookworm`](https://github.com/docker-library/postgres/blob/e00e1bd34ec5c8a8e7ad89b273b3d42efaf6d5bc/18/bookworm/Dockerfile)\n\n-\t[`18.6-alpine3.24`, `18-alpine3.24`, `alpine3.24`, `18.6-alpine`, `18-alpine`, `alpine`](https://github.com/docker-library/postgres/blob/e00e1bd34ec5c8a8e7ad89b273b3d42efaf6d5bc/18/alpine3.24/Dockerfile)\n\n-\t[`18.6-alpine3.23`, `18-alpine3.23`, `alpine3.23`](https://github.com/docker-library/postgres/blob/e00e1bd34ec5c8a8e7ad89b273b3d42efaf6d5bc/18/alpine3.23/Dockerfile)\n\n-\t[`17.11`, `17`, `17.11-trixie`, `17-trixie`](https://github.com/docker-library/postgres/blob/2603e26e245e558218728ee14e0a42dcb020dc7f/17/trixie/Dockerfile)\n\n-\t[`17.11-bookworm`, `17-bookworm`](https://github.com/docker-library/postgres/blob/2603e26e245e558218728ee14e0a42dcb020dc7f/17/bookworm/Dockerfile)\n\n-\t[`17.11-alpine3.24`, `17-alpine3.24`, `17.11-alpine`, `17-alpine`](https://github.com/docker-library/postgres/blob/2603e26e245e558218728ee14e0a42dcb020dc7f/17/alpine3.24/Dockerfile)\n\n-\t[`17.11-alpine3.23`, `17-alpine3.23`](https://github.com/docker-library/postgres/blob/2603e26e245e558218728ee14e0a42dcb020dc7f/17/alpine3.23/Dockerfile)\n\n-\t[`16.15`, `16`, `16.15-trixie`, `16-trixie`](https://github.com/docker-library/postgres/blob/9d15534160ade17f2b6c455a39ee967c49b1937d/16/trixie/Dockerfile)\n\n-\t[`16.15-bookworm`, `16-bookworm`](https://github.com/docker-library/postgres/blob/9d15534160ade17f2b6c455a39ee967c49b1937d/16/bookworm/Dockerfile)\n\n-\t[`16.15-alpine3.24`, `16-alpine3.24`, `16.15-alpine`, `16-alpine`](https://github.com/docker-library/postgres/blob/9d15534160ade17f2b6c455a39ee967c49b1937d/16/alpine3.24/Dockerfile)\n\n-\t[`16.15-alpine3.23`, `16-alpine3.23`](https://github.com/docker-library/postgres/blob/9d15534160ade17f2b6c455a39ee967c49b1937d/16/alpine3.23/Dockerfile)\n\n-\t[`15.19`, `15`, `15.19-trixie`, `15-trixie`](https://github.com/docker-library/postgres/blob/3cfb3b50d63453da51a439b25a1e18af563c3e2b/15/trixie/Dockerfile)\n\n-\t[`15.19-bookworm`, `15-bookworm`](https://github.com/docker-library/postgres/blob/3cfb3b50d63453da51a439b25a1e18af563c3e2b/15/bookworm/Dockerfile)\n\n-\t[`15.19-alpine3.24`, `15-alpine3.24`, `15.19-alpine`, `15-alpine`](https://github.com/docker-library/postgres/blob/3cfb3b50d63453da51a439b25a1e18af563c3e2b/15/alpine3.24/Dockerfile)\n\n-\t[`15.19-alpine3.23`, `15-alpine3.23`](https://github.com/docker-library/postgres/blob/3cfb3b50d63453da51a439b25a1e18af563c3e2b/15/alpine3.23/Dockerfile)\n\n-\t[`14.24`, `14`, `14.24-trixie`, `14-trixie`](https://github.com/docker-library/postgres/blob/cfa338619f694df7c72b8c15c3b52adc4392cfe9/14/trixie/Dockerfile)\n\n-\t[`14.24-bookworm`, `14-bookworm`](https://github.com/docker-library/postgres/blob/cfa338619f694df7c72b8c15c3b52adc4392cfe9/14/bookworm/Dockerfile)\n\n-\t[`14.24-alpine3.24`, `14-alpine3.24`, `14.24-alpine`, `14-alpine`](https://github.com/docker-library/postgres/blob/cfa338619f694df7c72b8c15c3b52adc4392cfe9/14/alpine3.24/Dockerfile)\n\n-\t[`14.24-alpine3.23`, `14-alpine3.23`](https://github.com/docker-library/postgres/blob/cfa338619f694df7c72b8c15c3b52adc4392cfe9/14/alpine3.23/Dockerfile)\n\n# Quick reference (cont.)\n\n-\t**Where to file issues**:  \n\t[https://github.com/docker-library/postgres/issues](https://github.com/docker-library/postgres/issues?q=is:issue+is:pr)\n\n-\t**Supported architectures**: ([more info](https://github.com/docker-library/official-images#architectures-other-than-amd64))  \n\t[`amd64`](https://hub.docker.com/r/amd64/postgres/), [`arm32v5`](https://hub.docker.com/r/arm32v5/postgres/), [`arm32v6`](https://hub.docker.com/r/arm32v6/postgres/), [`arm32v7`](https://hub.docker.com/r/arm32v7/postgres/), [`arm64v8`](https://hub.docker.com/r/arm64v8/postgres/), [`i386`](https://hub.docker.com/r/i386/postgres/), [`ppc64le`](https://hub.docker.com/r/ppc64le/postgres/), [`riscv64`](https://hub.docker.com/r/riscv64/postgres/), [`s390x`](https://hub.docker.com/r/s390x/postgres/)\n\n-\t**Published image artifact details**:  \n\t[repo-info repo's `repos/postgres/` directory](https://github.com/docker-library/repo-info/blob/master/repos/postgres) ([history](https://github.com/docker-library/repo-info/commits/master/repos/postgres))  \n\t(image metadata, transfer size, etc)\n\n-\t**Image updates**:  \n\t[official-images repo's `library/postgres` label](https://github.com/docker-library/official-images/issues?q=label%3Alibrary%2Fpostgres)  \n\t[official-images repo's `library/postgres` file](https://github.com/docker-library/official-images/blob/master/library/postgres) ([history](https://github.com/docker-library/official-images/commits/master/library/postgres))\n\n-\t**Source of this description**:  \n\t[docs repo's `postgres/` directory](https://github.com/docker-library/docs/tree/master/postgres) ([history](https://github.com/docker-library/docs/commits/master/postgres))\n\n# What is PostgreSQL?\n\nPostgreSQL, often simply \"Postgres\", is an object-relational database management system (ORDBMS) with an emphasis on extensibility and standards-compliance. As a database server, its primary function is to store data, securely and supporting best practices, and retrieve it later, as requested by other software applications, be it those on the same computer or those running on another computer across a network (including the Internet). It can handle workloads ranging from small single-machine applications to large Internet-facing applications with many concurrent users. Recent versions also provide replication of the database itself for security and scalability.\n\nPostgreSQL implements the majority of the SQL:2011 standard, is ACID-compliant and transactional (including most DDL statements) avoiding locking issues using multiversion concurrency control (MVCC), provides immunity to dirty reads and full serializability; handles complex SQL queries using many indexing methods that are not available in other databases; has updateable views and materialized views, triggers, foreign keys; supports functions and stored procedures, and other expandability, and has a large number of extensions written by third parties. In addition to the possibility of working with the major proprietary and open source databases, PostgreSQL supports migration from them, by its extensive standard SQL support and available migration tools. And if proprietary extensions had been used, by its extensibility that can emulate many through some built-in and third-party open source compatibility extensions, such as for Oracle.\n\n\u003e [wikipedia.org/wiki/PostgreSQL](https://en.wikipedia.org/wiki/PostgreSQL)\n\n![logo](https://raw.githubusercontent.com/docker-library/docs/01c12653951b2fe592c1f93a13b4e289ada0e3a1/postgres/logo.png)\n\n# How to use this image\n\n## start a postgres instance\n\n```console\n$ docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres\n```\n\nThe default `postgres` user and database are created in the entrypoint with `initdb`.\n\n\u003e The postgres database is a default database meant for use by users, utilities and third party applications.\n\u003e\n\u003e [postgresql.org/docs](https://www.postgresql.org/docs/14/app-initdb.html)\n\n## ... or via `psql`\n\n```console\n$ docker run -it --rm --network some-network postgres psql -h some-postgres -U postgres\npsql (14.3)\nType \"help\" for help.\n\npostgres=# SELECT 1;\n ?column? \n----------\n        1\n(1 row)\n```\n\n## ... via [`docker compose`](https://github.com/docker/compose)\n\nExample `compose.yaml` for `postgres`:\n\n```yaml\n# Use postgres/example user/password credentials\n\nservices:\n\n  db:\n    image: postgres\n    restart: always\n    # set shared memory limit when using docker compose\n    shm_size: 128mb\n    # or set shared memory limit when deploy via swarm stack\n    #volumes:\n    #  - type: tmpfs\n    #    target: /dev/shm\n    #    tmpfs:\n    #      size: 134217728 # 128*2^20 bytes = 128Mb\n    environment:\n      POSTGRES_PASSWORD: example\n\n  adminer:\n    image: adminer\n    restart: always\n    ports:\n      - 8080:8080\n```\n\nRun `docker compose up`, wait for it to initialize completely, and visit `http://localhost:8080` or `http://host-ip:8080` (as appropriate).\n\n# How to extend this image\n\nThere are many ways to extend the `postgres` image. Without trying to support every possible use case, here are just a few that we have found useful.\n\n## Environment Variables\n\nThe PostgreSQL image uses several environment variables which are easy to miss. The only variable required is `POSTGRES_PASSWORD`, the rest are optional.\n\n**Warning**: the Docker specific variables will only have an effect if you start the container with a data directory that is empty; any pre-existing database will be left untouched on container startup.\n\n### `POSTGRES_PASSWORD`\n\nThis environment variable is required for you to use the PostgreSQL image. It must not be empty or undefined. This environment variable sets the superuser password for PostgreSQL. The default superuser is defined by the `POSTGRES_USER` environment variable.\n\n**Note 1:** The PostgreSQL image sets up `trust` authentication locally so you may notice a password is not required when connecting from `localhost` (inside the same container). However, a password will be required if connecting from a different host/container.\n\n**Note 2:** This variable defines the superuser password in the PostgreSQL instance, as set by the `initdb` script during initial container startup. It has no effect on the `PGPASSWORD` environment variable that may be used by the `psql` client at runtime, as described at [https://www.postgresql.org/docs/14/libpq-envars.html](https://www.postgresql.org/docs/14/libpq-envars.html). `PGPASSWORD`, if used, will be specified as a separate environment variable.\n\n### `POSTGRES_USER`\n\nThis optional environment variable is used in conjunction with `POSTGRES_PASSWORD` to set a user and its password. This variable will create the specified user with superuser power and a database with the same name. If it is not specified, then the default user of `postgres` will be used.\n\nBe aware that if this parameter is specified, PostgreSQL will still show `The files belonging to this database system will be owned by user \"postgres\"` during initialization. This refers to the Linux system user (from `/etc/passwd` in the image) that the `postgres` daemon runs as, and as such is unrelated to the `POSTGRES_USER` option. See the section titled \"Arbitrary `--user` Notes\" for more details.\n\n### `POSTGRES_DB`\n\nThis optional environment variable can be used to define a different name for the default database that is created when the image is first started. If it is not specified, then the value of `POSTGRES_USER` will be used.\n\n### `POSTGRES_INITDB_ARGS`\n\nThis optional environment variable can be used to send arguments to `postgres initdb`. The value is a space separated string of arguments as `postgres initdb` would expect them. This is useful for adding functionality like data page checksums: `-e POSTGRES_INITDB_ARGS=\"--data-checksums\"`.\n\n### `POSTGRES_INITDB_WALDIR`\n\nThis optional environment variable can be used to define another location for the Postgres transaction log. By default the transaction log is stored in a subdirectory of the main Postgres data folder (`PGDATA`). Sometimes it can be desireable to store the transaction log in a different directory which may be backed by storage with different performance or reliability characteristics.\n\n**Note:** on PostgreSQL 9.x, this variable is `POSTGRES_INITDB_XLOGDIR` (reflecting [the changed name of the `--xlogdir` flag to `--waldir` in PostgreSQL 10+](https://wiki.postgresql.org/wiki/New_in_postgres_10#Renaming_of_.22xlog.22_to_.22wal.22_Globally_.28and_location.2Flsn.29)).\n\n### `POSTGRES_HOST_AUTH_METHOD`\n\nThis optional variable can be used to control the `auth-method` for `host` connections for `all` databases, `all` users, and `all` addresses. If unspecified then [`scram-sha-256` password authentication](https://www.postgresql.org/docs/14/auth-password.html) is used (in 14+; `md5` in older releases). On an uninitialized database, this will populate `pg_hba.conf` via this approximate line:\n\n```console\necho \"host all all all $POSTGRES_HOST_AUTH_METHOD\" \u003e\u003e pg_hba.conf\n```\n\nSee the PostgreSQL documentation on [`pg_hba.conf`](https://www.postgresql.org/docs/14/auth-pg-hba-conf.html) for more information about possible values and their meanings.\n\n**Note 1:** It is not recommended to use `trust` since it allows anyone to connect without a password, even if one is set (like via `POSTGRES_PASSWORD`). For more information see the PostgreSQL documentation on [*Trust Authentication*](https://www.postgresql.org/docs/14/auth-trust.html).\n\n**Note 2:** If you set `POSTGRES_HOST_AUTH_METHOD` to `trust`, then `POSTGRES_PASSWORD` is not required.\n\n**Note 3:** If you set this to an alternative value (such as `scram-sha-256`), you might need additional `POSTGRES_INITDB_ARGS` for the database to initialize correctly (such as `POSTGRES_INITDB_ARGS=--auth-host=scram-sha-256`).\n\n### `PGDATA`\n\n\u003e **Important Change:** [the `PGDATA` environment variable of the image was changed to be version specific in PostgreSQL 18 and above](https://github.com/docker-library/postgres/pull/1259). For 18 it is `/var/lib/postgresql/18/docker`. Later versions will replace `18` with their respective major version (e.g., `/var/lib/postgresql/19/docker` for PostgreSQL `19.x`). The defined `VOLUME` was changed in 18 and above to `/var/lib/postgresql`. Mounts and volumes should be targeted at the updated location. This will allow users upgrading between PostgreSQL major releases to use the faster `--link` when running `pg_upgrade` and mounting `/var/lib/postgresql`.\n\nUsers who wish to opt-in to this change on older releases can do so by setting `PGDATA` explicitly (`--env PGDATA=/var/lib/postgresql/17/docker --volume some-postgres:/var/lib/postgresql`). To migrate pre-existing data, adjust the volume's folder structure appropriately first (moving all database files into a `PG_MAJOR/docker` subdirectory).\n\n\u003e **Important Note:** (for PostgreSQL 17 and below) Mount the data volume at `/var/lib/postgresql/data` and not at `/var/lib/postgresql` because mounts at the latter path WILL NOT PERSIST database data when the container is re-created. The Dockerfile that builds the image declares a volume at `/var/lib/postgresql/data` and if no data volume is mounted at that path then the container runtime will automatically create an [anonymous volume](https://docs.docker.com/engine/storage/#volumes) that is not reused across container re-creations. Data will be written to the anonymous volume rather than your intended data volume and won't persist when the container is deleted and re-created.\n\nThis (`PGDATA`) is an environment variable that is not Docker specific. Because the variable is used by the `postgres` server binary (see the [PostgreSQL docs](https://www.postgresql.org/docs/14/app-postgres.html#id-1.9.5.14.7)), the entrypoint script takes it into account.\n\n## Docker Secrets\n\nAs an alternative to passing sensitive information via environment variables, `_FILE` may be appended to some of the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container. In particular, this can be used to load passwords from Docker secrets stored in `/run/secrets/\u003csecret_name\u003e` files. For example:\n\n```console\n$ docker run --name some-postgres -e POSTGRES_PASSWORD_FILE=/run/secrets/postgres-passwd -d postgres\n```\n\nCurrently, this is only supported for `POSTGRES_INITDB_ARGS`, `POSTGRES_PASSWORD`, `POSTGRES_USER`, and `POSTGRES_DB`.\n\n## Initialization scripts\n\nIf you would like to do additional initialization in an image derived from this one, add one or more `*.sql`, `*.sql.gz`, or `*.sh` scripts under `/docker-entrypoint-initdb.d` (creating the directory if necessary). After the entrypoint calls `initdb` to create the default `postgres` user and database, it will run any `*.sql` files, run any executable `*.sh` scripts, and source any non-executable `*.sh` scripts found in that directory to do further initialization before starting the service.\n\n**Warning**: scripts in `/docker-entrypoint-initdb.d` are only run if you start the container with a data directory that is empty; any pre-existing database will be left untouched on container startup. One common problem is that if one of your `/docker-entrypoint-initdb.d` scripts fails (which will cause the entrypoint script to exit) and your orchestrator restarts the container with the already initialized data directory, it will not continue on with your scripts.\n\nFor example, to add an additional user and database, add the following to `/docker-entrypoint-initdb.d/init-user-db.sh`:\n\n```bash\n#!/usr/bin/env bash\nset -e\n\npsql -v ON_ERROR_STOP=1 --username \"$POSTGRES_USER\" --dbname \"$POSTGRES_DB\" \u003c\u003c-EOSQL\n\tCREATE USER docker;\n\tCREATE DATABASE docker;\n\tGRANT ALL PRIVILEGES ON DATABASE docker TO docker;\nEOSQL\n```\n\nThese initialization files will be executed in sorted name order as defined by the current locale, which defaults to `en_US.utf8`. Any `*.sql` files will be executed by `POSTGRES_USER`, which defaults to the `postgres` superuser. It is recommended that any `psql` commands that are run inside of a `*.sh` script be executed as `POSTGRES_USER` by using the `--username \"$POSTGRES_USER\"` flag. This user will be able to connect without a password due to the presence of `trust` authentication for Unix socket connections made inside the container.\n\nAdditionally, as of [docker-library/postgres#253](https://github.com/docker-library/postgres/pull/253), these initialization scripts are run as the `postgres` user (or as the \"semi-arbitrary user\" specified with the `--user` flag to `docker run`; see the section titled \"Arbitrary `--user` Notes\" for more details). Also, as of [docker-library/postgres#440](https://github.com/docker-library/postgres/pull/440), the temporary daemon started for these initialization scripts listens only on the Unix socket, so any `psql` usage should drop the hostname portion (see [docker-library/postgres#474 (comment)](https://github.com/docker-library/postgres/issues/474#issuecomment-416914741) for example).\n\n## Database Configuration\n\nThere are many ways to set PostgreSQL server configuration. For information on what is available to configure, see the [PostgreSQL docs](https://www.postgresql.org/docs/14/runtime-config.html) for the specific version of PostgreSQL that you are running. Here are a few options for setting configuration:\n\n-\tUse a custom config file. Create a config file and get it into the container. If you need a starting place for your config file you can use the sample provided by PostgreSQL which is available in the container at `/usr/share/postgresql/postgresql.conf.sample` (`/usr/local/share/postgresql/postgresql.conf.sample` in Alpine variants).\n\n\t-\t**Important note:** you must set `listen_addresses = '*'`so that other containers will be able to access postgres.\n\n\t```console\n\t$ # get the default config\n\t$ docker run -i --rm postgres cat /usr/share/postgresql/postgresql.conf.sample \u003e my-postgres.conf\n\n\t$ # customize the config\n\n\t$ # run postgres with custom config\n\t$ docker run -d --name some-postgres -v \"$PWD/my-postgres.conf\":/etc/postgresql/postgresql.conf -e POSTGRES_PASSWORD=mysecretpassword postgres -c 'config_file=/etc/postgresql/postgresql.conf'\n\t```\n\n-\tSet options directly on the run line. The entrypoint script is made so that any options passed to the docker command will be passed along to the `postgres` server daemon. From the [PostgreSQL docs](https://www.postgresql.org/docs/14/app-postgres.html#id-1.9.5.14.6.3) we see that any option available in a `.conf` file can be set via `-c`.\n\n\t```console\n\t$ docker run -d --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword postgres -c shared_buffers=256MB -c max_connections=200\n\t```\n\n## Locale Customization\n\nYou can extend the Debian-based images with a simple `Dockerfile` to set a different locale. The following example will set the default locale to `de_DE.utf8`:\n\n```dockerfile\nFROM postgres:14.3\nRUN localedef -i de_DE -c -f UTF-8 -A /usr/share/locale/locale.alias de_DE.UTF-8\nENV LANG de_DE.utf8\n```\n\nSince database initialization only happens on container startup, this allows us to set the language before it is created.\n\nAlso of note, Alpine-based variants starting with Postgres 15 support [ICU locales](https://www.postgresql.org/docs/15/locale.html#id-1.6.11.3.7). Previous Postgres versions based on alpine do *not* support locales; see [\"Character sets and locale\" in the musl documentation](https://wiki.musl-libc.org/functional-differences-from-glibc.html#Character-sets-and-locale) for more details.\n\nYou can set locales in the Alpine-based images with `POSTGRES_INITDB_ARGS` to set a different locale. The following example will set the default locale for a newly initialized database to `de_DE.utf8`:\n\n```console\n$ docker run -d -e LANG=de_DE.utf8 -e POSTGRES_INITDB_ARGS=\"--locale-provider=icu --icu-locale=de-DE\" -e POSTGRES_PASSWORD=mysecretpassword postgres:15-alpine \n```\n\n## Additional Extensions\n\nWhen using the default (Debian-based) variants, installing additional extensions (such as PostGIS) should be as simple as installing the relevant packages (see [github.com/postgis/docker-postgis](https://github.com/postgis/docker-postgis/blob/81a0b55/14-3.2/Dockerfile) for a concrete example).\n\nWhen using the Alpine variants, any postgres extension not listed in [postgres-contrib](https://www.postgresql.org/docs/14/contrib.html) will need to be compiled in your own image (again, see [github.com/postgis/docker-postgis](https://github.com/postgis/docker-postgis/blob/81a0b55/14-3.2/alpine/Dockerfile) for a concrete example).\n\n# Arbitrary `--user` Notes\n\nAs of [docker-library/postgres#253](https://github.com/docker-library/postgres/pull/253), this image supports running as a (mostly) arbitrary user via `--user` on `docker run`. As of [docker-library/postgres#1018](https://github.com/docker-library/postgres/pull/1018), this is also the case for the Alpine variants.\n\nThe main caveat to note is that `postgres` doesn't care what UID it runs as (as long as the owner of `PGDATA` matches), but `initdb` *does* care (and needs the user to exist in `/etc/passwd`):\n\n```console\n$ docker run -it --rm --user www-data -e POSTGRES_PASSWORD=mysecretpassword postgres\nThe files belonging to this database system will be owned by user \"www-data\".\n...\n\n$ docker run -it --rm --user 1000:1000 -e POSTGRES_PASSWORD=mysecretpassword postgres\ninitdb: could not look up effective user ID 1000: user does not exist\n```\n\nThe three easiest ways to get around this:\n\n...\n\n**Note:** the description for this image is longer than the Hub length limit of 25000, so has been trimmed.  The full description can be found at [https://github.com/docker-library/docs/tree/master/postgres/README.md](https://github.com/docker-library/docs/tree/master/postgres/README.md).  See also [docker/hub-feedback#238](https://github.com/docker/hub-feedback/issues/238) and [docker/roadmap#475](https://github.com/docker/roadmap/issues/475).","permissions":{"read":true,"write":false,"admin":false},"media_types":["application/octet-stream","application/vnd.docker.container.image.v1+json","application/vnd.docker.distribution.manifest.list.v2+json","application/vnd.docker.distribution.manifest.v1+prettyjws","application/vnd.oci.image.index.v1+json"],"content_types":["unrecognized","image"],"categories":[{"name":"Databases \u0026 storage","slug":"databases-and-storage"}],"immutable_tags_settings":{"enabled":false,"rules":[".*"]},"storage_size":1866389046969,"source":null}