# Want to know differences between commit and volume

**URL:** <https://forums.docker.com/t/want-to-know-differences-between-commit-and-volume/27049>\
**Category:** General\
**Created:** [January 12, 2017, 8:00am UTC](https://forums.docker.com/t/want-to-know-differences-between-commit-and-volume/27049 "2017-01-12T08:00:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![leebduk](https://avatars.discourse-cdn.com/v4/letter/l/8dc957/32.png) [@leebduk](https://forums.docker.com/u/leebduk)\
**Post date:** [January 12, 2017, 8:00am UTC](https://forums.docker.com/t/want-to-know-differences-between-commit-and-volume/27049/1 "2017-01-12T08:00:35Z")

</div>

Hello

I’m new to docker, i have a questions about commit and volume. Some changes i made saved by committing but not all some changes that i made should be saved by volume. I want to know when i should use volume and commit to save data that i made changes to.

Thank you

---

<div class="post-metadata">

**Author:** ![dmaze](https://avatars.discourse-cdn.com/v4/letter/d/ea5d25/32.png) [@dmaze](https://forums.docker.com/u/dmaze)\
**Post date:** [January 12, 2017, 1:10pm UTC](https://forums.docker.com/t/want-to-know-differences-between-commit-and-volume/27049/2 "2017-01-12T13:10:34Z")

</div>

> [@leebduk](#):
>
> I’m new to docker, i have a questions about commit and volume. Some changes i made saved by committing but not all some changes that i made should be saved by volume. I want to know when i should use volume and commit to save data that i made changes to.

Never use `docker commit`.

Do learn how `docker build` works. Write a custom `Dockerfile` for your application.

Now, to answer your original question: think about the first time you start your application. What data do you absolutely need to be present for it to start? That should probably be “baked in” to your image: `COPY` it in the `Dockerfile`, and it will always be there. Now think about the second time you start your application. What data do you need to have not lost? That should be in volumes, possibly provided via the `docker run -v` option.

You should expect, and plan for, the container itself to be deleted. So if you:

```auto
docker build -t me/something .
docker run --name x -v /here:/there me/something
docker rm x
docker run --name x -v /here:/there me/something

```

everything should still work as you expect, and you shouldn’t have lost data.

---

<div class="post-metadata">

**Author:** ![leebduk](https://avatars.discourse-cdn.com/v4/letter/l/8dc957/32.png) [@leebduk](https://forums.docker.com/u/leebduk)\
**Post date:** [January 13, 2017, 2:13am UTC](https://forums.docker.com/t/want-to-know-differences-between-commit-and-volume/27049/3 "2017-01-13T02:13:11Z")

</div>

Hi thanks for replying

I understood what you said then i got two questions  
My first plan was to start with ubuntu images to build my server cause i want to use it as like a virtual machine to test a lot of things.  
So my question is that docker is not an appropriate to use for my cases?  
From your answer i felt docker should be used after finish server settings to launch easily is it right?  
Another question is that then why apt-get install command is saved by commit command

Thank you
