Volumes Flashcards

1
Q

What are Volumes?

A

The way the filesystem of a docker container is stored and used

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Each volume act like a separate ___

A

Drive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the types of volumes?

A
  • Anonymous volume
  • Named volume
  • Bind Volume
  • Tmpf Volume
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

By default, Docker uses what kind of volume?

A

Anonymous volume

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the 2 ways we can create a new volume?

A
  1. docker-compose.yml file

2. Docker Desktop app

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do we create a volume in the docker-compose.yml file?

A

Need:

  • Volumes section
  • Declare name of new volume
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do we create a volume in Docker Desktop app?

A
  1. Click ‘New Volume’ button

2. Enter volume name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Add the volume ‘my_volume’ to this docker-compose.yml file located at var/www/log

A
webserver:
     build: ./app1
     ports:
          - "80"
     volumes:
          - my_volume:/var/www/log
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Can the same volume be mounted on multiple containers?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A file can only be written to ____ to avoid lockup/access issues

A

one container at a time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A file can only be written to ____ to avoid lockup/access issues

A

one container at a time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the 2 types of syntax you can use when declaring a volume?

A
  1. Short syntax

2. Long syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is short syntax?

Give an example

A

volumes:

- new_volume:/var/www/log

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is long syntax?

Give an example

A

volumes:

 - type: volume
   source: my_new_volume
   target: /var/www/log
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is long syntax?

Give an example

A

volumes:

 - type: volume
   source: my_new_volume
   target: /var/www/log
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What can you use for the source in short syntax?

A
  • Name

- Path

17
Q

What can you use for the source in long syntax?

A
  • Name
18
Q

What can you use for the source in long syntax?

A
  • Name
19
Q

What is are Bind Volumes?

A

Binds a local folder on the host to the container

20
Q

What is a pro to using Bind Volumes?

A

Allows easy access on the host

21
Q

What is a con to using Bind Volumes?

A

Risky when deploying between hosts as permissions may not work

22
Q

How can you make a volume read-only?

Why might you do this?

A
volumes:
     - type: volume
       source: my_new_volume
       target: /var/www/log
       read_only: true

You can config files that containers need by shouldn’t modify

23
Q

How can you make a volume nocopy?

Why might you do this?

A
volumes:
     - type: volume
       source: my_new_volume
       target: /var/www/log
       volume:
           nocopy: true

Good if you have a shared volume but you want it to occupy a space that would have had others files in it already

24
Q

Which type of volume doesn’t use the source command?

A

Tmpf Volumes

25
Q

Why might you use tmpf?

A

If youre working with sensitive data

You want to limit size

26
Q

Declare a tmpf volume with max size of 100B

A

volumes:

 - type: tmpfs
   target: /var/www/log
   tmpfs:  
        size: 100B
27
Q

What is the peculiarity of using tmpfs on the WSL (Windows Subsystem for Linux)?

A
  • Doesnt support tmpfs
  • Writes to a file instead of memory, which isn’t cleared when the container is killed
  • Doesnt respect the size command
28
Q

What is the peculiarity of using tmpfs on the WSL (Windows Subsystem for Linux)?

A
  • Doesnt support tmpfs
  • Writes to a file instead of memory, which isn’t cleared when the container is killed
  • Doesnt respect the size command
29
Q

What type of volume would never have files be copied from the underlying container into the volume during setup? Why?

A

Bound Volumes

Security issue: Files could be copied anywhere on the host, meaning file can end up somewhere it shouldn’t