Probably the letsencrypt docker does not find the nextcloud docker under its name. This should be resided but the docker internal dns service but only works if the containers share the same docker network. Is your nextcloud docker named "nextcloud" and is it joined in a docker network with the letsencrypt container?
Thank you! I think that might have been the reason.