サンプル問題 1: Which functionality is provided by Vagrant as well as by Docker? (Choose three.)
A: Both can share directories from the host file system to a guest.
B: Both start system images as containers instead of virtual machines by default.
C: Both can download required base images.
D: Both can apply changes to a base image.
E: Both start system images as virtual machines instead of containers bv default.
正解:A, C, D
Explanation: Both Vagrant and Docker can share directories from the host file system to a guest. This allows the guest to access files and folders from the host without copying them. Vagrant uses the config.vm.synced_folder option in the Vagrantfile to specify the shared folders1. Docker uses the -v or --volume flag in the docker run command to mount a host directory as a data volume in the container2. Both Vagrant and Docker can download required base images. Base images are the starting point for creating a guest environment. Vagrant uses the config.vm.box option in the Vagrantfile to specify the base image to use1. Docker uses the FROM instruction in the Dockerfile to specify the base image to use2. Both Vagrant and Docker can download base images from public repositories or local sources. Both Vagrant and Docker can apply changes to a base image. Changes are modifications or additions to the base image that customize the guest environment. Vagrant uses provisioners to run scripts or commands on the guest after it is booted1. Docker uses instructions in the Dockerfile to execute commands on the base image and create a new image2. Both Vagrant and Docker can save the changes to a new image or discard them after the guest is destroyed. Vagrant and Docker differ in how they start system images. Vagrant starts system images as virtual machines by default, using a provider such as VirtualBox, VMware, or Hyper-V1. Docker starts system images as containers by default, using the native containerization functionality on macOS, Linux, and Windows2. Containers are generally more lightweight and faster than virtual machines, but less secure and flexible. Reference: 1: Vagrant vs. Docker | Vagrant | HashiCorp Developer 2: Vagrant vs Docker: Which Is Right for You? (Could Be Both) - Kinsta® Web Development Tools
サンプル問題 2: Which of the following network interface types are valid in an LXD container configuration? (Choose three.)
A: ipsec
B: macvlan
C: bridged
D: physical
E: wifi
正解:B, C, D
Explanation: LXD supports the following network interface types in an LXD container configuration1: macvlan: Creates a virtual interface on the host with a unique MAC address and attaches it to an existing physical interface. This allows the container to have direct access to the physical network, but prevents communication with the host and other containers on the same host2. bridged: Connects the container to an existing bridge interface on the host. This allows the container to communicate with the host and other containers on the same bridge, as well as the external network if the bridge is connected to a physical interface3. physical: Passes an existing physical interface on the host to the container. This allows the container to have exclusive access to the physical network, but removes the interface from the host4. The other network interface types, ipsec and wifi, are not valid in an LXD container configuration. Ipsec is a protocol for secure communication over IP networks, not a network interface type. Wifi is a wireless technology for connecting devices to a network, not a network interface type. Reference: About networking - Canonical LXD documentation Macvlan network - Canonical LXD documentation Bridge network - Canonical LXD documentation Physical network - Canonical LXD documentation
サンプル問題 3: Which of the following statements in a Dockerfile leads to a container which outputs hello world? (Choose two.)
A: ENTRYPOINT "echo Hello World"
B: ENTRYPOINT [ "echo hello world" ]
C: ENTRYPOINT [ "echo", "hello", "world" ]
D: ENTRYPOINT echo Hello World
E: ENTRYPOINT "echo", "Hello", "World*
正解:B, C
Explanation: The ENTRYPOINT instruction in a Dockerfile specifies the default command to run when a container is started from the image. The ENTRYPOINT instruction can be written in two forms: exec form and shell form. The exec form uses a JSON array to specify the command and its arguments, such as [ “executable”, “param1”, “param2” ]. The shell form uses a single string to specify the command and its arguments, such as “executable param1 param2”. The shell form is converted to the exec form by adding /bin/sh -c to the beginning of the command. Therefore, the following statements in a Dockerfile are equivalent and will lead to a container that outputs hello world: ENTRYPOINT [ “echo hello world” ] ENTRYPOINT [ “/bin/sh”, “-c”, “echo hello world” ] ENTRYPOINT “echo hello world” ENTRYPOINT [ “echo”, “hello”, “world” ] ENTRYPOINT [ “/bin/sh”, “-c”, “echo”, “hello”, “world” ] ENTRYPOINT “echo hello world” The other statements in the question are invalid or incorrect. The statement A. ENTRYPOINT “echo Hello World” is invalid because it uses double quotes to enclose the entire command, which is not allowed in the shell form. The statement D. ENTRYPOINT echo Hello World is incorrect because it does not use quotes to enclose the command, which is required in the shell form. The statement E. ENTRYPOINT “echo”, “Hello”, “World” is invalid because it uses double quotes to separate the command and its arguments, which is not allowed in the exec form. Reference: Dockerfile reference | Docker Docs Using the Dockerfile ENTRYPOINT and CMD Instructions - ATA Learning Difference Between run, cmd and entrypoint in a Dockerfile