Will this command mount the host's '/data' directory to the ubuntu container in read-only mode?
Solution: 'docker run -v /data:/mydata --mode readonly ubuntu'
Correct Answer: B
= The command docker run -v /data:/mydata --mode readonly ubuntu is not valid because it has some syntax errors. The correct syntax for running a container with a bind mount is docker run [OPTIONS] IMAGE [COMMAND] [ARG...]. The errors in the command are:
The option flag for specifying the volume is --volume or -v, not -v. For example, -v /data:/mydata should be --volume /data:/mydata.
The option flag for specifying the mode of the volume is --mount, not --mode. For example, --mode readonly should be --mount type=bind,source=/data,target=/mydata,readonly.
The option flag for specifying the mode of the container is --detach or -d, not --mode. For example, --mode readonly should be --detach.
The correct command for running a container with a bind mount in read-only mode is:
docker run --volume /data:/mydata --mount type=bind,source=/data,target=/mydata,readonly --detach ubuntu This command will run a container using the ubuntu image and mount the host's /data directory to the container's /mydata directory in read-only mode. The container will run in the background (--detach).
docker run reference | Docker Documentation : [Use bind mounts | Docker Documentation]