I wrote a blog post that explains how to access an unpublished port of a container In different ways depending on the needs:
The post also goes through a brief introduction of both how port mapping works, the difference between exposing and publishing a port, and what is socat.
Here’s the link: https://lmcaraig.com/accessing-an-unpublished-port-of-a-running-docker-container