Platform | Number of Instance | Reading Time |
---|---|---|
Play with Docker | 1 | 5 min |
- Create a Docker volume and pull Alpine image
- Create files in Alpine
- Verify the existence of Docker volume
Create a Docker volume to which you will add persistent data.
docker volume create --name mydata
Create a Docker container, attach the data volume, and add persistent data. Pull a lightweight Alpine distribution image. docker pull alpine
Create a container from Alpine and mount the volume mydata to /mnt.
docker run -ti --name client -v mydata:/mnt alpine /bin/sh
Go to the /mnt directory, touch (create) two files, and verify they exist.
cd /mnt
touch foo.txt
touch bar.txt
ls
Exit the container.
exit
docker ps -a
Delete the container and then verify that it is gone.
docker rm client
docker ps –a
docker run --rm -ti -v mydata:/mnt alpine /bin/sh
cd /mnt
ls
exit
docker volume ls
docker rm -f $(docker ps -aq) .
docker rmi $(docker images -q)
docker volume rm $(docker volume ls -q)
Sangam biradar -https://engineitops.github.io