🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Docker Tutorials: Specify the size limit while creating the docker volume?

If you want to use Volume with Containers, please refer this url.

Volumes are often a better choice than persisting data in a container’s writable layer, because a volume does not increase the size of the containers using it, and the volume’s contents exist outside the lifecycle of a given container.

When its comes to a question of How to specify the size limit while creating the docker volume?

As we can see it’s possible to create docker volumes with a predefined size and do it from Docker API which is especially useful if you’re creating new volumes from some container with mounted docker socket and don’t have access to the host.

But Currently, Its looks like only tmpfs mounts support disk usage limitations.

It is possible to specify the size limit while creating the docker volume using size param with –opt options.

# docker -v
Docker version 19.03.9, build 9d988398e7
# docker volume create -h
Flag shorthand -h has been deprecated, please use --help
Usage: docker volume create [OPTIONS] [VOLUME]
Create a volume
Options:
-d, --driver string Specify volume driver name (default "local")
--label list Set metadata for a volume
-o, --opt map Set driver specific options (default map[])
Docker Command Example
Some of the storage driver plugins which is used for limiting a volume size are
- flocker
- local
- convoy
Here is example command provided in the documentation to specify the same
$ docker volume create --driver flocker -o size=20GB my-named-volume
$ docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000
$ docker volume create --driver local --opt type=btrfs --opt device=/dev/sda2
$ docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000 foo
$ docker volume create --driver convoy --opt size=100m test
Docker Compose Example
volumes:
tmpfs:
# For details, see:
# https://docs.docker.com/engine/reference/commandline/volume_create/#driver-specific-options
driver: local
driver_opts:
o: "size=$TMPFS_SIZE"
device: tmpfs
type: tmpfs

Good reference
https://medium.com/@dmitrytk/limit-docker-volume-size-9859682f4147

Docker Tutorials Fundamental To Advanced-2021 Crash Course:- https://bit.ly/3hOIbTB

Subscribe
Notify of
guest


0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x