Skip to content

Latest commit

 

History

History
84 lines (70 loc) · 1.37 KB

File metadata and controls

84 lines (70 loc) · 1.37 KB

Persistence

Volumes

Create volume:

docker volume create <volume-name>

Mount container with Volume:

docker run /*cmds*/ --mount type=volume,src=<volume-name>,target=<path-in-container-to-store-volume> <image-name>

Look at volume(s):

docker volume inspect

Bind Mounts

Mount:

docker run /*cmds*/ --mount type=bind,src="$(pwd)/secrets",target=/env <image-name>

Where:

--mount 
    type=bind     => bind mount
    src="$(pwd)/secret"  => sets source directory (on local fs) to <pwd>/secrets
    target=/env   => links(and creates) root/env dir in container, and links to src dir in local fs 
                  

Table

Volume Bind Mount
Storage In a FS managed by docker In the hosts FS
Access Via docker only Any process with FS access
Data sharing Multiple container can use the same volume at the same time Only one container can use the data at the same time
Use Cases Cloud and remote friendly Config, source code