nerdexam
Docker

DCA · Question #5

A container named "analytics" that stores results in a volume called "data" was created. docker run -d --name=analytics -v data:/data app1 How are the results accessed in "data" with another…

The correct answer is B. docker run -d --name=reports --volumes-from=analytics app2. To allow a new container to access an existing volume attached to another container, use the --volumes-from option.

Submitted by klara.se· Apr 18, 2026Storage and Volumes

Question

A container named "analytics" that stores results in a volume called "data" was created. docker run -d --name=analytics -v data:/data app1 How are the results accessed in "data" with another container called "app2"?

Options

  • Adocker run -d --name=reports --volume=data app2
  • Bdocker run -d --name=reports --volumes-from=analytics app2
  • Cdocker run -d --name=reports --volume=app1 app2
  • Ddocker run -d --name=reports --mount=app1 app2

How the community answered

(21 responses)
  • A
    10% (2)
  • B
    81% (17)
  • C
    5% (1)
  • D
    5% (1)

Why each option

To allow a new container to access an existing volume attached to another container, use the `--volumes-from` option.

Adocker run -d --name=reports --volume=data app2

The command `docker run -d --name=reports --volume=data app2` is incomplete for directly mapping an existing named volume; it requires specifying both the volume name and the container mount path (e.g., `-v data:/data`).

Bdocker run -d --name=reports --volumes-from=analytics app2Correct

The `docker run --volumes-from=analytics app2` command enables the new container (`app2`) to mount all volumes that were mounted in the specified source container (`analytics`), thereby providing access to the shared 'data' volume.

Cdocker run -d --name=reports --volume=app1 app2

`app1` is the name of the image used by the first container, not a valid volume name or container name to be referenced with `--volume`.

Ddocker run -d --name=reports --mount=app1 app2

`--mount=app1` is an incorrect syntax for mounting volumes; `app1` is an image name and not a valid mount source or configuration parameter.

Concept tested: Sharing volumes between Docker containers

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

Topics

#Docker Volumes#Named Volumes#Container Data Sharing#--volumes-from

Community Discussion

No community discussion yet for this question.

Full DCA Practice