Also the port you opened to change the default port is only for external services or clients. Immich-server uses the internal network for connecting to postgres, which still uses the default port. You should just use immich-database:5432
and not change anything.
as @walden already mentioned, the files in Lemmy’s documentation are the wrong ones. The correct file seems to be in https://github.com/LemmyNet/lemmy/blob/main/docker/docker-compose.yml.
The documentation won’t help you if you don’t want to use Ansible.