Docker containers are
volatile
, which means the
data
inside the docker containers will be
deleted
as soon as the container dies.
So to make the data
persistent
we need to
attach
a
volume
while starting a docker container.
The volume can be attached to a container by passing
-v flag
The
syntax
for attaching a volume to a docker container is
docker run -v <source_volume>:<container_volume> -d <image_name>
The user can also attach
NFS share, object storage
, etc as
volume
to the container.
So even if the docker container
died
, user can
restart
the container by passing the
source
volume
All the
local volumes
can be
listed
by typing
docker volume ls
Click to learn more