Docker, montera fysisk disk: Difference between revisions
Jump to navigation
Jump to search
Linuxwiki>Wikiadmin Skapade sidan med '=== Montera en fysisk disk i en container === Källa: https://serverfault.com/questions/1053820/can-docker-volumes-be-mounted-from-a-device-instead-of-bind-mounting-a-directory # Create "my-volume" '''docker volume create --driver=local --opt type=ext4 --opt device=/dev/disk/by-uuid/d28c6d3a-461e-4d7d-8737-40e56e8f384a my-volume''' # Run a container with it mounted to a path. '''docker run -v my-volume:/my-volume --rm -it alpine sh''' Kategori:Docker' |
m 2 revisions imported |
||
| (One intermediate revision by one other user not shown) | |||
| Line 2: | Line 2: | ||
Källa: https://serverfault.com/questions/1053820/can-docker-volumes-be-mounted-from-a-device-instead-of-bind-mounting-a-directory | Källa: https://serverfault.com/questions/1053820/can-docker-volumes-be-mounted-from-a-device-instead-of-bind-mounting-a-directory | ||
On a linux docker host this is possible by first creating named volume with a local driver. | |||
The named volume is just a specification for what to mount when the container starts so the device does not need to be plugged in when the volume is created. | |||
From docker you first create a named volume. Let's say the device I want to mount is an ext4 drive and will always appear as /dev/disk/by-uuid/d28c6d3a-461e-4d7d-8737-40e56e8f384a: | |||
# Create "my-volume" | # Create "my-volume" | ||
'''docker volume create --driver=local --opt type=ext4 --opt device=/dev/disk/by-uuid/d28c6d3a-461e-4d7d-8737-40e56e8f384a my-volume''' | '''docker volume create --driver=local --opt type=ext4 --opt device=/dev/disk/by-uuid/d28c6d3a-461e-4d7d-8737-40e56e8f384a my-volume''' | ||
Latest revision as of 21:53, 11 May 2026
Montera en fysisk disk i en container
On a linux docker host this is possible by first creating named volume with a local driver.
The named volume is just a specification for what to mount when the container starts so the device does not need to be plugged in when the volume is created.
From docker you first create a named volume. Let's say the device I want to mount is an ext4 drive and will always appear as /dev/disk/by-uuid/d28c6d3a-461e-4d7d-8737-40e56e8f384a:
# Create "my-volume" docker volume create --driver=local --opt type=ext4 --opt device=/dev/disk/by-uuid/d28c6d3a-461e-4d7d-8737-40e56e8f384a my-volume # Run a container with it mounted to a path. docker run -v my-volume:/my-volume --rm -it alpine sh