I noticed that if the service name of the MediaWiki Container is the same as the domain e.g.:
... services: my-wiki.com: image: mediawiki:1.35.0 container_name: my-wiki.com ...
VisualEditor will fail with either 404 or curl error 7
After suffixing or prefixing the service and container_name with an arbitrary string like:
... services: my-wiki.com_mw: image: mediawiki:1.35.0 container_name: my-wiki.com_mw ...
VisualEditor successfully connected to Parsoid PHP.
The issue is, that containers running in compose automatically resolve to their name to the local ip of the container. In this case it tries to connect to the domain using the name (as intended) but then getting the local ip back which causes the error (at least when running https)