If I would like to create a data volume of let´s say 15GB that would be of type ext4, how would I do that?
docker volume create --name vol
just creates an empty volume.
docker volume create --opt type=ext4 --name vol
creates an ext4 volume but I cannot specify the size of it since ext4 does not support it according to the mount options of ext4.
You can check size of your docker system. If you want to check from where your containers take storage, you can inspect your volume. In my case, my container takes storage from /var/lib/docker/volumes/myvol1/_data and this file is available in my local system.
In Dockerfile you can specify only the destination of a volume inside a container. e.g. /usr/src/app . When you run a container, e.g. docker run --volume=/opt:/usr/src/app my_image , you may but do not have to specify its mounting point ( /opt ) on the host machine.
In the current Docker version, there is a default limitation on the Docker container storage of 10Gb. As the BlazeMeter image is ~5 GB when the sample.
You can manage volumes using Docker CLI commands or the Docker API. Volumes work on both Linux and Windows containers. Volumes can be more safely shared among multiple containers. Volume drivers let you store volumes on remote hosts or cloud providers, to encrypt the contents of volumes, or to add other functionality.
It is possible to specify the size limit while creating the docker volume using size
as per the documentation
Here is example command provided in the documentation to specify the same
docker volume create -d flocker -o size=20GB my-named-volume
UPDATE Some more examples from git repository:
The built-in local driver on Linux accepts options similar to the linux mount command:
$ docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000
Another example:
$ docker volume create --driver local --opt type=btrfs --opt device=/dev/sda2
Using Docker Compose I was able to do it the following way:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With