Docker Container No route to host error

I have a similar problem when running wp-super-cache plugin on WordPress using Docker for Mac. The cURL calls from wp-super-cache from inside my WordPress container to http://localhost:8081 (I am mapping ports using -p 8081:80) are failing.

There are many other posts on this problem on this forum. This is the one I got most info from:

And this is the official documentation on workarounds for the issue as far as I can see. In my case, as the call is being made from a third party plugin, I may have to hack it to update the address the cURL command uses. I will see if I can make it work.