The difference between "-v" and "-mount" in docker is: when using "-v" to mount the host directory, if there is no specified file on the host, no error will be reported, and the specified file will be automatically created; when When using "-mount", if there is no such file in the host, an error will be reported and the specified file cannot be found, and the specified file will not be automatically created.
The operating environment of this tutorial: linux7.3 system, docker-1.13.1 version, Dell G3 computer.
What is the difference between -v and -mount in docker
##--volume(-v)
The parameter --volume (or -v for short) can only create a bind mount. Example: dockerdocker run --name $CONTAINER_NAME -it \ -v $PWD/$CONTAINER_NAME/app:/app:rw \ -v $PWD/$CONTAINER_NAME/data:/data:ro \ avocado-cloud:latest /bin/bash
--mount
Parameter --mount is used to mount volume by default, but can also be used to create bind mount and tmpfs. If the type option is not specified, the default is to mount volume. Volume is a more flexible data management method. Volume can be managed through the docker volume command set. Example: bashdocker run --name $CONTAINER_NAME -it \ --mount type=bind,source=$PWD/$CONTAINER_NAME/app,destination=/app \ --mount source=${CONTAINER_NAME}-data,destination=/data,readonly \ avocado-cloud:latest /bin/bash
docker video tutorial》
The above is the detailed content of What is the difference between -v and -mount in docker. For more information, please follow other related articles on the PHP Chinese website!