I meant the default port of the MySQL hub container is 3306, but I was typing 3312 instead. So is there any problem that occurred, after I ran that, there was no error and I still can use MySQL in bash.
Thank you!
I don’t really know what you mean by typing the wrong port. Typing where? You have to explain your issues for people who have no idea about your environment and deployment.
By MySQL hub container I guess you mean the MySQL image on Docker hub. MySQL uses port 3306, that has nothing to do with containers. Using containers you can use that port inside the container and forward another port to it from the host. The applications using the docker networks internally will still have to use port 3306, so it doesn’t matter how you change the port forward as long as you don’T change the port on which the MySQL server is listening in the container.
So igf I guessed well, there is no risk off forwarding a different port unless there is something listening on that port as well and you can accidentally serving your data to the public. And of course you don’t want to open ports for no reason.
Hello
Default port is indeed 3306 and you can expose that one… or do a port mapping saying that internal port 3306 of the mysql container is mapped on your host to port 3312. There is problem at all here.
I do this when i’m running several projects having thus more than one mysql container : each container has his own port (3307 for the first, 3308 for the second,…).
No risk, you can simply do it like that.
Side note: We use Docker Swarm (for multiple nodes) with compose files and Docker network, so apps can access the database internally, we never have to open any port on host, that’s even more secure.