docker run with volume code example
Example 1: docker mount volume
docker run -v /host/directory:/container/directory -other -options image_name command_to_run
Example 2: docker run with volume docker api
"HostConfig": {
"Mounts": [
{
"Target": "path/in/the/container",
"Source": "volume1",
"Type": "volume",
"ReadOnly": false
}
]
}
Example 3: docker volumes copy content
CID=$(docker run -d -v hello:/hello busybox true)
docker cp $CID:/hello ./