A Docker image is a collection of read-only layers. When you
launch a container from an image, Docker adds a read-write layer to the top of
that stack of read-only layers. Docker calls this the Union File System.
Any time a file is changed, Docker makes a copy of the file from
the read-only layers up into the top read-write layer. This leaves the original
(read-only) file unchanged.
When a container is deleted,
that top read-write layer is lost. This means that any changes made after the
container was launched are now gone.
Mounting a volume is a good solution if you want to:
· Push
data to a container.
· Pull
data from a container.
· Share data between
containers.
A Docker volume "lives" outside the container, on the
host machine.
From the container, the volume acts like a folder which you can
use to store and retrieve data. It is simply a mount point to a directory on
the host.
To create a volume, use the command:
sudo docker volume create
--name [volume name]
List Volumes
To list all Docker volumes on the system, use the command:
sudo docker volume ls
This will return a list of all of the Docker volumes which have
been created on the host.
Inspect a Volume
To inspect a named volume, use the command:
sudo docker volume inspect
[volume name]
To remove a named volume, use the command:
sudo docker volume rm [volume
name]
No comments:
Post a Comment