Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How persistent are docker data-only containers

Tags:

docker

I'm a bit confused about data-only docker containers. I read it's a bad practice to mount directories directly to the source-os: https://groups.google.com/forum/#!msg/docker-user/EUndR1W5EBo/4hmJau8WyjAJ

And I get how I make data-only containers: http://container42.com/2014/11/18/data-only-container-madness/

And I see somewhat similar question like mine: How to deal with persistent storage (e.g. databases) in docker

But what if I have a lamp-server setup.. and I have everything nice setup with data-containers, not linking them 'directly' to my source-os and make a backup once a while..

Than someone comes by, and restarts my server.. How do I setup my docker (data-only)-containers again, so I don't lose any data?

like image 868
11mb Avatar asked Oct 19 '22 12:10

11mb


1 Answers

Actually, even though it was shykes who said it was considered a "hack" in that link you provide, note the date. Several eons worth of Docker years have passed since that post about volumes, and it's no longer considered bad practice to mount volumes on the host. In fact, here is a link to the very same shykes saying that he has "definitely used them at large scale in production for several years with no issues". Mount a host OS directory as a docker volume and don't worry about it. This means that your data persists across docker restarts/deployments/whatever. It's right there on the disk of the host, and doesn't go anywhere when your container goes away.

I've been using docker volumes that mount host OS directories for data storage (database persistent storage, configuration data, et cetera) for as long as I've been using Docker, and it's worked perfectly. Furthermore, it appears shykes no longer considers this to be bad practice.

like image 151
L0j1k Avatar answered Nov 15 '22 06:11

L0j1k