Reputation: 639
Let me describe my situation.
I have a mysql docker running as below in a Azure VM:
docker ps output:
67b7d4f1eca6 2c9028880e58 "docker-entrypoint.s…" 4dayago Up7hours(healthy) 3306/tcp, 33060/tcp mysql
docker image ls output:
something.azurecr.io/mysql latest 2c9028880e58 3 months ago 447MB
uname -a
Linux pradipmazure1 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Now as we can see the mysql is not exposed to any outside port such that I can see it from my workstation outside of the VM.
I can not redeploy the whole VM anymore as it's a part of prod.
I would like to do something such that the mysql can potentially be exposed outside in some port of the same Azure Linux VM.
Any help in this regard would be highly appreciated.
Thanks, Pradip
Upvotes: 0
Views: 226
Reputation: 25070
You can redirect the incoming traffic on port 3306 (or whatever port you want to expose MySql on) to port 3306 in the container. The container has an IP address on the bridge network that is reachable from the host. You can find the IP address of your container by running
docker inspect network bridge
When you've found the IP address, you can use redir
to redirect the traffic with
redir --lport=3306 --caddr=172.17.0.2 --cport=3306
You need to run redir
on the host. lport
is the port you want to listen on. caddr
is the IP address of the container.
For a cleaner solution you could even run redir
in a new container. This might help you if you want to go that way: https://hub.docker.com/r/fr3nd/redir
Upvotes: 1
Reputation: 11006
The only solution I have in mind, because you can't recreate the MySQL container, is to link containers which need MySQL by the deprecated --link
option.
Upvotes: 0