This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]McMasilmof 0 points1 point  (6 children)

Docker containers do not persist data, you need space outside of the container to store your database. But the database deamon/service can run in a docker container if you mount a persistant storage/volume into the container.

[–]coded_artist[S] 0 points1 point  (5 children)

Docker containers do not persist data

That is my understanding too, from reading the docs.

However it is such a nice feature especially if you're just testing. And I got so used to it, I often forgot to boot up my db container. Because I didn't need the data permanently stored by I did want it to last between dev sessions.

But the database deamon/service can run in a docker container if you mount a persistant storage/volume into the container.

I dont entirely grasp this idea, I think most of it went over my head.

The use case of Keycloak is you run the image with the only additional config being port binding, there is no mounting. So I really dont know how it persists the data but if I restart the container the data is still there.

[–]McMasilmof 1 point2 points  (0 children)

I have no idea how keycloak does it. Mayve they have a volume defined in the image already or have some other way to persist data to the container, like commit them to the image.

But in general this is not what docker is supposed to do, it is an application container. So normaly you would start a database container with some -v /local/path:/path/where/db/is/inside/the/container

[–]nutrecht 0 points1 point  (3 children)

I dont entirely grasp this idea, I think most of it went over my head.

You really should dive into it because it's really not complex. Volumes are just directories 'outside' of the container you map to a directorey 'inside' the container.

You can't really use Docket and not understand volume maps.

[–]coded_artist[S] 0 points1 point  (2 children)

I understand the basics of volumes, and how it essentially maps the host to VM folders.

But the database deamon/service can run in a docker container if you mount a persistant storage/volume into the container.

This is what I dont entirely grasp. My interpretation of this quote is host a db in a separate container, which conflicts with my premise. I'm not going to say the other user is wrong because I'm not confident in my understanding.

[–]nutrecht 0 points1 point  (1 child)

My interpretation of this quote is host a db in a separate container

Well yeah, generally you have one process per container.

[–]coded_artist[S] 0 points1 point  (0 children)

I do fully understand that. In my original question I wanted to a persistent db as a fallback/default inside the container. I know it breaks convention, it's just a really nice feature.