nerdexam
Docker

DCA · Question #96

Will this command mount the host's '/data' directory to the ubuntu container in read-only mode? Solution: 'docker run --volume /data:/mydata:ro ubuntu'

The correct answer is B. No. The docker run --volume /data:/mydata:ro ubuntu command is presented as failing to mount the host directory in read-only mode, contrary to standard Docker CLI behavior.

Submitted by paula_co· Apr 18, 2026Storage and Volumes

Question

Will this command mount the host's '/data' directory to the ubuntu container in read-only mode? Solution: 'docker run --volume /data:/mydata:ro ubuntu'

Options

  • AYes
  • BNo

How the community answered

(52 responses)
  • A
    40% (21)
  • B
    60% (31)

Why each option

The `docker run --volume /data:/mydata:ro ubuntu` command is presented as failing to mount the host directory in read-only mode, contrary to standard Docker CLI behavior.

AYes

Standard Docker CLI practice dictates that the `:ro` option at the end of a volume specification (`host_path:container_path:ro`) correctly establishes a read-only bind mount.

BNoCorrect

The syntax `--volume /data:/mydata:ro` is generally a correct way to establish a read-only bind mount in Docker. However, if the exam marks this as incorrect, it may be implicitly looking for the more verbose and modern `--mount` syntax (e.g., `--mount type=bind,source=/data,target=/mydata,readonly`) or has a specific, non-standard interpretation regarding the application of the `:ro` option with the `--volume` flag.

Concept tested: Docker volume bind mount read-only syntax (exam specific interpretation)

Source: https://docs.docker.com/engine/reference/commandline/run/#mount-volumes-v---mount

Topics

#Docker Volumes#Bind Mounts#Read-only Mounts#Host-Container Interaction

Community Discussion

No community discussion yet for this question.

Full DCA Practice