Storing Container Data In Docker Volumes

samiullahsaleem

Sami Ullah Saleem

Posted on August 14, 2023

Storing Container Data In Docker Volumes

Let's learn about volumes in Docker
What you will learn?

  • Anonymous Volumes
  • Create a Docker Volume
  • Use the Website Volume with Containers
  • Clean Up Unused Volumes

1. Anonymous Volumes
When we create a container then automatically docker creates an anonyous volume for that container.

Anonymous Volume

Now, lets inspect the volume using the following command

Inspect Information

2- Create a Docker Volume

~ docker volume create webiste
~ docker volume ls
Enter fullscreen mode Exit fullscreen mode

Creating Volume using docker

3. Use the Website Volume with Containers

~ docker run -d --name web1 -p 80:80 -v webiste:/usr/local/apache2/htdocs:ro httpd:2.4
Enter fullscreen mode Exit fullscreen mode

4- Clean Up Unused Volumes

~ docker volume prune
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
samiullahsaleem
Sami Ullah Saleem

Posted on August 14, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related