Search code examples
databasedockerkubernetes

Run Database as Docker container or on a bare metal server?


Databases are designed to consume all memory, CPU and IO available to them. Is there are good/bad reasons Docker should not be used for databases in production?

May be this question applies to other tools like MOMs Apache Kafka, Apache ActiveMQ etc.


Solution

  • Docker is not a full-scale virtual machine (at least when run on Linux), this is just another process, running on the same kernel, as host machine. Moreover, all docker container processes can be seen in a host machine with ps aux.

    The only additional load Docker gives is loading another OS on top of your kernel, but actually most containers are deployed with extremely lightweight stuff like alpine Linux, so I dont think it really has to be taken into consideration.

    From another point, having Database (or any other high load service) in a containers gives you following advantages:

    • Scaling (containers can easily be spread among nodes with container orchestration tools like k8s)
    • Easy deploy (all dependencies are inside)
    • Easy upgrade (just replace the container)
    • Easy testing (no need for db-cleaning procedures in advance of running tests) and others

    So deploying containerized services today is a right practice.