Storage Flashcards
Storage location of non-persistent data
/var/lib/docker/Storage-driver/
Third party drivers for persistent volumes
- block storage(amazon efs, open stack cindr) good for high performance
- file storage (uses protocol such as nfs, smb) good for high performance workloads
- object storage - large blobs that do not often change (amazon s3, sef, mino)
Storage location of persistent data
/var/lib/docker/volumes/
List all Docker volume commands
docker volume -h
List all volumes
docker volume ls
Create volume
docker volume create volume_name
Get the flags available when creating a volume
docker volume create -h
Inspecting a volume
docker volume inspect volume_name
Deleting a volume
docker volume rm volume_name
Removing all unused volumes
docker volume prune
Bind mounts with mount flag type=bind
they are not managed by __docker volume__
docker container run -d –name container_name –mount type=bind,source=source,target=target_in_container image_name
example:
1. mkdir my_target
2 .docker container run -d \
–name nginx-bind-mount1 \
–mount type=bind,source=”$(pwd)”/me_target,target=/app nginx
3. touch my_target/file1
4. docker container exec -it nginx-bind-mount1 /bin/bash
5. ls /app => file1
Bind mounts with volume flag
docker container run -d –name container_name –volume:source:target image_name
example:
1. docker container run -d –name nginx-bind-mount2 \
-v “$(pwd)”/my_new_target:/app nginx
creating my_new_target prior running a container is not necessary, this will be created automatically
2. docker container exec -it nginx-bind-mount2 touch /app/myfile
3. ls ~/my_new_target/ => myfile
Bind mounts with mount flag type=volume
they are managed by __docker volume__
docker container run -d --name container_name --mount type=volume,source=source,target=target_in_container image_name 1. docker volume create html_volume 2 .docker container run -d \ --name nginx-volume1 \ --mount type=volume,source=html_volume,target=/usr/share/nginx/html/ \ nginx 3. docker volume inspect html_volume 4. Creating a volume using that volume flag docker container run -d \ --name nginx-volume2 \ -v html_volume:/usr/share/nginx/html/ \ nginx
Using a read-only volume:
- docker run -d \
–name=nginx-volume3 \
–mount source=html_volume,target=/usr/share/nginx/html,readonly \
nginx - docker container exec -it nginx-volume3 /bin/bash
- vim /usr/share/nginx/html/index.html => this is read only