I have a postgress database installed in a Docker container called dbDocker. This container is not using any of the server ports and the container's port for postgres 5342 is only visible from containers in the same virtual network. I want to create another docker container to allow users out of the network to contact that database. Is it possible to do this? So, this new container will appear as the one having the database.
Thanks
Yes, the software you ask about is called a proxy.
You can have a container that exposes a port. When someone connects, it connects somewhere else and passes the data back-and-forth staying as a man in the middle.
In fact as you expose any port in docker (like
-p 3306:3306
), the docker runs internally a proxy. A very unsophisticated one, without much access granularity.An example of a more advanced proxy for your scenario is containerized haproxy, configured with
mode tcp
(as postgress is incompatible withmode http
).Another example is the dreaded SOCKS proxy.
If I got you wrong, and what you need is only to simply expose on 127.0.0.1 then see this answer.