Docker Volume
If you copy or create a file in a container when you stop that container that file or the other files we created or copied will be deleted.Solution for this is using Docker Volume.
There are 4 commands that we will work with them:
- docker volume ls
- docker volume create
- docker volume inspect
- docker volume rm
we start with docker volume create:
docker volume create --name data
Now if we use docker volume ls it will show the volume.
If you want to see full descriptions about a volume we can use docker volume inspect data.
There are 3 important parts in the outcome one of them is driverif you run it on a network you can mount it or its on a local host.
We need 2 directories for Docker volume:
- We saw the first one in docker volume inspect data
- The second one is where we want to save our files on it.
This command will mount a volume inside a container:
docker run --name youcanputanythinghere -d -v data:/var/data ubuntu
If you didn't undrestand anything this video may help you undrestand Docker Volume in 6 minutes:

