In the previous post we’ve learnt some of the most useful Docker Containers commands. In this post, we’ll investigate volumes in detail and see how we can run either State-full or State-less containers.

Docker Volume is essentially a disk space assigned to your container. All you need to do to use volumes in Docker environment is to declare, or attach it, while creating an instance of container. Alternatively, you can also attach an existing volume at container create time.


Create Volume

You can also create a new instance of a volume on your Docker system, which you’ll then be able to bind to a container. To create one, use the volume create command.

More details: docker volume create cli

Create Volume

docker volume create [VOLUME NAME]

Create Volume with Flags

docker volume create [FLAG] [VOLUME NAME]

Flags

–name Volume name
–label Volume metadata
-d Specify volume driver name

List Volumes

To check what volumes you have already created in your system, use the volume ls command.

More details: docker volume ls cli

docker volume ls

Inspect Volume

To have a closer look into an instance of a volume for features such as driver, scope or mount point use the volume inspect command.

More details: docker volume inspect cli

docker volume inspect [VOLUME NAME]

Remove Volume

It’s always a good idea to remove volume on your Docker system that you don’t need anymore. To do so use the volume rm command.

More details: docker volume rm cli

Remove Volume by Name

docker volume rm [VOLUME NAME]

Force Remove Volume

docker volume rm -f [VOLUME NAME]

<< Docker Containers | Docker Volumes | Docker Housekeeping >>

Marcin Narloch

Marcin Narloch

Creative and out-of-the-box thinker with strong interests and knowledge in technology and innovation.
Docker Building Blocks Previous post Docker Housekeeping
Docker Building Blocks Next post Docker Containers

Leave a Reply

Your email address will not be published. Required fields are marked *