Goal
Recreate db so it also publishes port 5432, keeping the same image, password and pgdata volume — and the data in it.
You can't add a port, a variable or a mount to an existing container. You replace it. That sounds alarming until you've moved the state into a volume — then the container is disposable and replacing it is routine.
This is the core habit of working with containers: treat them as cattle, not pets, and keep anything precious in volumes.
Try it
Recreate the database with a published port and check the data survived.
Don't try to "upgrade" by swapping postgres:16 for postgres:17 on the same volume — try it and read the logs. Major versions need a real migration (pg_upgrade or a dump and restore).