Maybe you could check the answer given here How to test a PHP API in a Docker container ? This is not directly your question, but is related to curl error within docker context.
Don't hesitate adding your dockerfile and docker-compose, if you need more help.