Skip to content

Update README.md #2508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,21 @@ $ docker run -it --rm --user 1000:1000 -e POSTGRES_PASSWORD=mysecretpassword pos
initdb: could not look up effective user ID 1000: user does not exist
```

The three easiest ways to get around this:
The four easiest ways to get around this:

1. allow the image to use [the `nss_wrapper` library](https://cwrap.org/nss_wrapper.html) to "fake" `/etc/passwd` contents for you (see [docker-library/postgres#448](https://github.com/docker-library/postgres/pull/448) for more details)
1. on the host, use the same UID:GID that the container defines for postgres user/group. These are 999:999 for Debian based containers and 70:70 for Alpine based containers.

2. bind-mount `/etc/passwd` read-only from the host (if the UID you desire is a valid user on your host):
2. allow the image to use [the `nss_wrapper` library](https://cwrap.org/nss_wrapper.html) to "fake" `/etc/passwd` contents for you (see [docker-library/postgres#448](https://github.com/docker-library/postgres/pull/448) for more details)

3. bind-mount `/etc/passwd` read-only from the host (if the UID you desire is a valid user on your host):

```console
$ docker run -it --rm --user "$(id -u):$(id -g)" -v /etc/passwd:/etc/passwd:ro -e POSTGRES_PASSWORD=mysecretpassword postgres
The files belonging to this database system will be owned by user "jsmith".
...
```

3. initialize the target directory separately from the final runtime (with a `chown` in between):
4. initialize the target directory separately from the final runtime (with a `chown` in between):

```console
$ docker volume create pgdata
Expand Down
Loading