Last active
September 6, 2022 15:12
-
-
Save rleap-m/7d6c8fbc3cc2cf231c8869d94e1bf10c to your computer and use it in GitHub Desktop.
Using Volumes on Windows - Bind Mount (aka Host Mount) Container Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a 'Bind Mount' (as opposed to a Named volume which is managed by Docker) | |
# https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/persistent-storage | |
# Linux - SELinux - make sure your mount point isn't something like /home or /usr | |
docker container run --rm -it -v "$(pwd)"/containerdata:/data:Z rleapm/mke-mgmt:lnx-1.2 | |
# Windows | |
# 'Node Path' or 'Host Path' is 'C:\Users\Public\Documents\ContainerData' | |
# 'Container Path' is 'C:\data' | |
# Data written to 'c:\data' by/from within the Container will be persisted on | |
# the host server in 'C:\Users\Public\Documents\ContainerData' | |
docker run -it -v C:\Users\Public\Documents\ContainerData:C:\data:RW mcr.microsoft.com/powershell | |
# Again, HOST_DIR:CONTAINER_DIR | |
docker container run -it -v c:\scripts:c:\external mcr.microsoft.com/powershell | |
# This is a volume mount | |
docker volume create leapvolume | |
docker volume inspect leapvolume | |
[ | |
{ | |
"CreatedAt": "2021-01-21T12:40:08Z", | |
"Driver": "local", | |
"Labels": {}, | |
"Mountpoint": "C:\\ProgramData\\docker\\volumes\\leapvolume\\_data", | |
"Name": "leapvolume", | |
"Options": {}, | |
"Scope": "local" | |
} | |
] | |
# Without ContainerAdministrator I couldn't access the volume for reading/writing | |
docker container run --rm -dt --name leap-test ` | |
>> -v leapvolume:C:\data -u ContainerAdministrator mcr.microsoft.com/powershell:lts-nanoserver-1809 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment