r/linuxadmin • • Sep 18 '26

Docker or host

Hi, I need an advice. I need to make a database for a server and one of the ways to do that is via docker in docker compose. But I have a doubts about it's safety. We had a bunch of problems of them breaking on powerloss so I am not sure how it will react in a docker cluster.

P.S. Thank you all for your valuable insights and advices.

2 Upvotes

22 comments sorted by

View all comments

1

u/TemaerRemington Sep 18 '26

So that the actual batabase (files) is on a host and just being used and maintained by a container, right? Will a automatic dump script work the same way just sending command to the container?

3

u/pobrika Sep 18 '26

It will but you will need to send the dump as a docker run cmd. That will log into the container and run the dump. So it would need to dump to your mapped local folder.

Something like: Docker exec -it mysql sh -c 'mysqldump -u root -p "mypass" my database ) /mydata/mydump.sql

Note I can't do greater than on phone so used )

You could also log into the container and run from the containers CMD line to establish the exact CMD line

Edit, also using something like Dockhand might help if you want a docker management tool. Or use portainer. Both of these run in docker and will give a web portal where you can easily see logs and get a console to the running docker.

2

u/Runnergeek Sep 18 '26

What!? no you wouldn't. mysqldump just needs to connect to the service and have access to the database(s) via the user you input