305-300 practice question 2 of 15

Which functionality is provided by Vagrant as well as by Docker? (Choose three.)

Full set: 121 questions
Answer options
A: Both can share directories from the host file system to a guest. Correct answer
B: Both start system images as containers instead of virtual machines by default.
C: Both can download required base images. Correct answer
D: Both can apply changes to a base image. Correct answer
E: Both start system images as virtual machines instead of containers bv default.
Correct Answer:
A. Both can share directories from the host file system to a guest.; C. Both can download required base images.; D. Both can apply changes to a base image.
Explanation

Vagrant and Docker share several core functionalities despite their different primary use cases (VMs vs. containers). Both tools can map a directory from the host operating system into the guest environment for file sharing; Vagrant uses "synced folders," while Docker uses "bind mounts." Both systems are built upon the concept of base images. Vagrant downloads "boxes" from Vagrant Cloud, and Docker pulls "images" from a registry like Docker Hub. Furthermore, both allow users to make modifications to a running instance (a VM or a container) and then save those changes as a new, reusable base image. Vagrant uses the vagrant package command, while Docker uses docker commit or, more commonly, a Dockerfile with docker build.

Why Incorrect

B. Vagrant's default providers, such as VirtualBox or Hyper-V, create full virtual machines. While a Docker provider exists, it is not the default behavior.
E. Docker is a containerization platform and does not create or manage virtual machines; it exclusively runs containers which share the host's kernel.

References

1. Directory Sharing (A):

HashiCorp Vagrant Documentation. (n.d.). Synced Folders - Basic Usage. Retrieved from https://developer.hashicorp.com/vagrant/docs/synced-folders/basicusage. (This page describes how config.vm.syncedfolder maps a host path to a guest path).

Docker Documentation. (n.d.). Bind mounts. Retrieved from https://docs.docker.com/storage/bind-mounts/. (This document explains using the --mount or -v flag to mount a host file or directory into a container).

2. Downloading Base Images (C):

HashiCorp Vagrant Documentation. (n.d.). Boxes - Base Boxes. Retrieved from https://developer.hashicorp.com/vagrant/docs/boxes/base. (Section "Finding More Boxes" explains that Vagrant downloads boxes from Vagrant Cloud).

Docker Documentation. (n.d.). docker pull. Retrieved from https://docs.docker.com/engine/reference/commandline/pull/. (This page details how Docker pulls images from a configured registry if not found locally).

3. Applying Changes to a Base Image (D):

HashiCorp Vagrant Documentation. (n.d.). Command: package. Retrieved from https://developer.hashicorp.com/vagrant/docs/cli/package. (This document describes packaging a Vagrant environment into a reusable box).

Docker Documentation. (n.d.). docker commit. Retrieved from https://docs.docker.com/engine/reference/commandline/commit/. (This page explains how to create a new image from a container's changes).

4. Vagrant vs. Docker Architecture (B, E):

Fox, A., & Patterson, D. (2016). CS 169: Software Engineering, Lecture 18: Virtual Machines, Containers, Cloud. UC Berkeley. Retrieved from https://inst.eecs.berkeley.edu/~cs169/fa16/lectures/18-vms-containers-cloud.pdf. (Slides 15-25 compare the architectures, highlighting Vagrant's use of Type-2 Hypervisors for VMs versus Docker's container model).

Scroll to Top