When running containers with Docker Compose, I sometimes want to access an unpublished port from a dependency container. For example, I sometimes need to connect directly to a database running inside a compose stack.
The usual solution is to edit (docker-)compose.yml and recreate the container with a published port. This works, but it is disruptive when the service is already running.
After experimenting a bit, I discovered two ways to expose container ports without recreating the containers. I'll document those in this post.
[!NOTE]