docker-library/docs

Document mentioning port forwarding

erich5168 opened this issue · 2 comments

Novice here....

Curious, Is there a reason there is no mentioning of port mapping in the docs?

If -p 3306:3306 is still the proper way of exposing MySQL container to other application outside of Docker, is it possible to include this in just one of the example or have a small section that talkes about it?

The docs here are specific for each individual image so we try to keep it concise. Port publishing and networking docs are over at Docker's main docs for the engine itself https://docs.docker.com/config/containers/container-networking/

We also get a lot of users who don't understand what they're doing copy-pasting our examples verbatim, and without making sure your MySQL instance is secure in other ways (strong password, firewall outside your Docker box since Docker will bypass one on the box, etc), it's not a great idea to expose that port directly -- what I'd typically recommend instead is having a Docker network shared with the application and the database together, which removes the need to expose the port in most cases (and is then more secure as the database isn't exposed publicly).