Give access from a custom docker to another container

In order to run CalCardBackup (BernieO/calcardbackup: Bash script to backup calendars and addressbooks from a local ownCloud/Nextcloud installation - Forgejo: Beyond coding. We Forge.) in a docker that can access the Nextcloud DB, I must somehow give access to CalCardBackup container to the nextcloud postgres container.
Now when it tried to access the DB using the right credential, it gets: could not resolve hostname.
I guess I must add something in the network option of the CalCardBackup docker container. What it should be?

I’m on EE, nextcloud is an old instance that I just need to recover some calendar, then I will delete as I moved to a fresh instance of nextcloud (obviously under a different name).

Thanks for any help.

you must know which network the db container uses and add the calcardbackup container to the same network

Ok, thanks @LarsR for the hint.
I figured out now with docker documentation:
Here is the solution for future in the same situation:
Once the custom docker running and working find it’s container name:
In TrueNAS shell or via SSH as root:
docker container ls
Find your custom container name, in my case: ix-calcardbackup-calcardbackup-1 (first I use the name under network, this was not the right one, double check for you).
Then list all the docker networks:
docker network ls
copy the network ID of the app you want to give access to your custom docker. It’s some random string abc123def456
Then connect the container running to this existing network:
docker network connect abc123def456 ix-calcardbackup-calcardbackup-1 (replace the container by yours if different)
VOILA! CalCardBackup docker (the main and only container here) can access all Nextcloud docker containers including the postgres db one the it needs.

Of course understand what you are doing and which access you give to which program. In my case it’s just to do a one time recovery, I will then delete nextcloud and calcardbackup anyway, but you might need to disconnect it if access is not more needed. I could have give access to my new nextcloud instance and make regular backup in this way but I prefer to ask user to activate the backup of calendar and contact in the Nextcloud app on mobile, then the backup is in a file in their account, not need to access the db in case of nextcloud crash, everything needed is in the files.