简体   繁体   中英

Create a Docker container with MySQL/MariaDB database

I'm planning to migrate my application stack to Docker. Let me describe the services I'm currently using:

  • HAProxy , which is used for SSL termination on all service's connections (HTTP and raw TCP connections), and forwards traffic to the services below.
  • Nginx , which serves static files, like updates and some information pages.
  • Node.js , which runs the main applications.
  • MySQL (MariaDB) , the database used and shared by all the applications.

My question is about the database.

What's the proper way of running MariaDB in this case?

  1. Install and run it inside my container, along with the other services?
  2. Run the official image in a separate container, and link my container to it with the --link option of Docker's run command?

Does the first option have any disadvantage?

TeamSpeak docker container uses the second option and that's what made me question myself about the correct way of running the database in my case, but I particularly feel more inclined to package all the services inside my own image.

Docker Philosophy: Split your application into microservices and use a container for each microservice .

In your case, I recommend a MariaDB container, Using official ( Library ) Image gives you easier update management, but feel free to use your custom image.

An HAProxy Container, A nginx container and a nodejs container.

This way you divided your application into microservices , and you can upgrade, manage and troubleshoot them easier in an isolated environment.

If you are thinking about delivering your application to end users via docker, a simple docker-compose file will do the trick for easy launching the required containers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM