Open McDuck opened 2 months ago
Does the username actually matter? The filesystem doesn't store the username -- I'm guessing it's actually complaining about the UID (not the username), and that passing --user explicit-UID:explicit-GID
on your docker run
line would fix it (use something like stat -c '%u:%g' postgresql_data.old
to find the correct value).
It does seem to matter. Permissions are set correctly. Passing the correct --user fails identically.
Do you have a full reproducer? (Just the conversion doesn't exactly help me reproduce.)
I can comment broadly on the scenario I ran in to.
The containers were databases for an Authentik
compose project.
OLD
some-db:
container_name: some-db
image: postgres:12-alpine
volumes:
- ./storage/db/data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_DB: some-db
NEW
some-db:
container_name: some-db
image: postgres:16-alpine
volumes:
- ./storage/db/data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_DB: some-db
The volume folders were created during the initial run of the container.
This resulted in the error above.
The next step I took, was to find the UID:GID of the data using the command you outlined. I then added user: xxx:xxx
to the compose file. This resulted in an identical error. I then made the changes suggested by OP and the error resolved. I'm trying to understand why this would work too. But it did seem to work. Unfortunately I've migrated removed OLD
. So I can't recreate it.
In the NEW
container and on the host both permissions show 70:70 which is the postgres
user from the container as expected.
It's very possible I also didn't do something correctly, but then again I am not sure why the fix would have worked for me either.
Reproduce
Able to migrate from old postgresql db which has a custom installed username .
Current
It fails with
database user "postgres" is not the install user
:With
--username=somecustomusername
it fails withFATAL: role "somecustomusername" does not exist
:Reason
Hardcoded username
postgres
. E.g. https://github.com/tianon/docker-postgres-upgrade/blob/5ac0d88908565f63a97ccd9ad318d9ed892dcd76/13-to-16/Dockerfile#L26Workaround
Edit the
Dockerfile
: