nerdexam
Docker

DCA · Question #1

Which of the following commands wifi automatically create a volume when a container is started?

The correct answer is A. 'docker container run --name nginxtest --volumes=/app nginx'. To automatically create an anonymous volume when starting a container, the docker container run command should use the -v /container/path or --volumes=/container/path syntax.

Submitted by brentm· Apr 18, 2026Storage and Volumes

Question

Which of the following commands wifi automatically create a volume when a container is started?

Options

  • A'docker container run --name nginxtest --volumes=/app nginx'
  • B'docker container run --name nginxtest -v /app:mount nginx'
  • C'docker container run --name nginxtest --volumes myvol:/app:new nginx'
  • D'docker container run --name nginxtest -v myvol:/app nginx'

How the community answered

(36 responses)
  • A
    75% (27)
  • B
    3% (1)
  • C
    8% (3)
  • D
    14% (5)

Why each option

To automatically create an anonymous volume when starting a container, the `docker container run` command should use the `-v /container/path` or `--volumes=/container/path` syntax.

A'docker container run --name nginxtest --volumes=/app nginx'Correct

The `docker container run --volumes=/app` command, equivalent to `-v /app`, instructs Docker to automatically provision and manage a new anonymous volume, without a user-defined name, and mount it inside the container at the specified path `/app`.

B'docker container run --name nginxtest -v /app:mount nginx'

This command specifies a bind mount, which maps a host directory (`/app`) to a container directory (`mount`), rather than creating a Docker-managed volume.

C'docker container run --name nginxtest --volumes myvol:/app:new nginx'

The syntax `--volumes myvol:/app:new` is incorrect; the `:new` option is not a valid part of the volume flag syntax for creating or mounting a volume.

D'docker container run --name nginxtest -v myvol:/app nginx'

This command uses a named volume (`myvol`); while Docker creates `myvol` if it doesn't exist, it is explicitly named by the user, distinguishing it from the automatically named anonymous volume in option A.

Concept tested: Anonymous volume creation

Source: https://docs.docker.com/storage/volumes/#create-and-manage-volumes

Topics

#Docker Volumes#docker run command#Anonymous Volumes#Volume creation

Community Discussion

No community discussion yet for this question.

Full DCA Practice