Volumes Flashcards
What are Volumes?
The way the filesystem of a docker container is stored and used
Each volume act like a separate ___
Drive
What are the types of volumes?
- Anonymous volume
- Named volume
- Bind Volume
- Tmpf Volume
By default, Docker uses what kind of volume?
Anonymous volume
What are the 2 ways we can create a new volume?
- docker-compose.yml file
2. Docker Desktop app
How do we create a volume in the docker-compose.yml file?
Need:
- Volumes section
- Declare name of new volume
How do we create a volume in Docker Desktop app?
- Click ‘New Volume’ button
2. Enter volume name
Add the volume ‘my_volume’ to this docker-compose.yml file located at var/www/log
webserver: build: ./app1 ports: - "80" volumes: - my_volume:/var/www/log
Can the same volume be mounted on multiple containers?
Yes
A file can only be written to ____ to avoid lockup/access issues
one container at a time
A file can only be written to ____ to avoid lockup/access issues
one container at a time
What are the 2 types of syntax you can use when declaring a volume?
- Short syntax
2. Long syntax
What is short syntax?
Give an example
volumes:
- new_volume:/var/www/log
What is long syntax?
Give an example
volumes:
- type: volume source: my_new_volume target: /var/www/log
What is long syntax?
Give an example
volumes:
- type: volume source: my_new_volume target: /var/www/log