Which flag is used when launching a Docker container to map a volume?

Prepare for the Cisco Certified DevNet Associate Exam. Use flashcards and multiple choice questions to boost your knowledge, with hints and explanations to guide you. Ace your exam effectively!

The -v flag is used when launching a Docker container to specify a volume mapping between the host system and the container. This mapping allows for persistent data storage, enabling data to be retained even if the container is stopped or removed.

When using the -v flag, you can define the host directory or file that you want to map to a directory or file within the container. This is particularly useful for scenarios where you want to share configuration files, media files, or any other data between the container and the host. For example, if you want a container to access a specific directory on your host filesystem for reading or writing files, you would use the -v flag followed by the host path and the container path.

Other flags serve different purposes. The -d flag is used to run the container in detached mode, meaning it will run in the background. The -p flag is used to map port numbers between the host and the container for network communication. The --name flag allows you to give a custom name to your container for easier management and identification. While all these flags are useful, the -v flag specifically addresses the requirement for volume mapping.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy