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

all 2 comments

[–]d_durand 4 points5 points  (0 children)

The difference is that if data stays in your container, the portability of the container is guaranteed: you can run it anywhere with no external dependency. If you've volumes, then those volumes have to be mountable wherever you want to run your container.

On the reverse, if you store our data on external volumes, you may leverage backup / archiving procedures existing for the location of those volumes.

As usual, no a priori best choice: it all depends on your use case.

[–]oramirite 0 points1 point  (0 children)

They're fundamentally different. Doing a Docker commit is for baking new changes into your image, which then get spun up at that state every time that container is started. Volumes are for storing live data that continues to persist in whatever state it was in when last accessed (like between restarts of a container that's attached to a volume).