LCA Virtualization & Container Management 2 — Questions and Answers
Question 1: Which command displays all running and stopped Docker containers?
- docker ps
- docker ps -a (Correct answer)
- docker list --all
- docker container show
Correct answer: docker ps -a
The '-a' flag with 'docker ps' lists all containers regardless of state, including stopped ones.
Question 2: In KVM virtualization, what file format natively supports snapshots, encryption, and compression?
- raw
- vmdk
- qcow2 (Correct answer)
- vhd
Correct answer: qcow2
QCOW2 (QEMU Copy-On-Write v2) is KVM's native format supporting snapshots, encryption, and thin provisioning.
Question 3: What is the purpose of the 'docker network create' command?
- Expose container ports to the host
- Create an isolated network for container communication (Correct answer)
- Link two running containers
- Configure DNS for Docker daemon
Correct answer: Create an isolated network for container communication
'docker network create' defines a new network that containers can join to communicate with each other in isolation.
Question 4: Which libvirt tool is used to manage virtual networks from the command line?
- virt-install
- virsh (Correct answer)
- virt-manager
- qemu-system-x86_64
Correct answer: virsh
virsh is the command-line interface for libvirt and can manage networks, domains, storage, and more.
Question 5: A Dockerfile instruction 'COPY . /app' is run during which phase?
- Container start
- Image build (Correct answer)
- Container runtime
- Registry push
Correct answer: Image build
COPY and other Dockerfile instructions execute during 'docker build', creating image layers.
Question 6: What does setting 'cpu_shares' on a cgroup accomplish for a virtual machine?
- Pins the VM to a specific CPU core
- Sets the relative CPU scheduling weight (Correct answer)
- Limits total CPU time to a fixed percentage
- Disables CPU hyperthreading for the VM
Correct answer: Sets the relative CPU scheduling weight
cpu_shares assigns a relative weight used by the scheduler when CPU contention occurs among cgroup members.
Question 7: Which command saves a Docker image to a tar archive file?
- docker export
- docker save (Correct answer)
- docker commit
- docker dump
Correct answer: docker save
'docker save' exports an image (including all layers and metadata) to a tar file for offline transfer.
Which command displays all running and stopped Docker containers?