DEV Community

Cover image for Storing Container Data In Docker Volumes
Sami Ullah Saleem for AWS Community Builders

Posted on

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

Top comments (0)