Hi Community, Currently I am trying to implement some eCommerce functionality in java. And I would like to pull data from MySQL and utilize the same. So for this purpose I wanted to use MySQL docker container for the first time. And in my Linux server(host) I have installed docker and created a custom MySQL container with Image. so here the question is how to use this container in my local computer. And is this the way we suppose to access MySQL from local ?? or we create a different container for our local server by installing docker from the image? And how to access this container from host server (I mean the endpoint). Could someone please elaborate the clear use case of MySQL docker container. if you have any questions for my query please ask so that I will reply in comments.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
If you want to be able to access the MySQL container form the outside world, what you need to do is when starting the MySQL container is to bind the container to the host port with the -p flag. For example, for MySQL it would look like this -p 3306:3306.
However, what I’ve personally have been doing recently is avoiding running my SQL servers in containers. Instead, I use the Managed Database Clusters which come with high availability and disaster recovery. I still have my Java applications inside containers which then connect to the managed clusters.
That way I kind of get best of the both worlds. I can scale my application by adding more containers and I can scale my databases thanks to all of the features that come with the Managed Database Clusters.
Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.