1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
docker volume create my-vol docker volume ls
docker volume inspect my-vol
docker run -d -P \ --name web \ --mount source=my-vol,target=/usr/share/nginx/html \ nginx:alpine
docker inspect web
"Mounts": [ { "Type": "volume", "Name": "my-vol", "Source": "/var/lib/docker/volumes/my-vol/_data", "Destination": "/usr/share/nginx/html", "Driver": "local", "Mode": "", "RW": true, "Propagation": "" } ],
$ docker volume rm my-vol
docker run --mount type=bind,source=/host/directory,target=/container/directory other_options image_name
$ docker run -d -P \ --name web \ --mount type=bind,source=/src/webapp,target=/usr/share/nginx/html \ nginx:alpine
$ docker inspect web "Mounts": [ { "Type": "bind", "Source": "/src/webapp", "Destination": "/usr/share/nginx/html", "Mode": "", "RW": true, "Propagation": "rprivate" } ],
$ docker run --rm -it \ --mount type=bind,source=$HOME/.bash_history,target=/root/.bash_history \ ubuntu:18.04 \ bash
root@2affd44b4667:/ 1 ls 2 diskutil list
|