Scripting, Containers, and Automation for CompTIA Linux+

This page covers the Scripting, Containers, and Automation domain of the CompTIA Linux+ certification. Master Cybersecurity offers 176 practice questions in this domain, drawn from the same content we use across our timed exam simulations. Below are five sample questions with full answer explanations.

Sample Practice Questions

  1. Question 1

    An application developer received a file with the following content [Dockerfile content displayed]. The developer must use this information to create a test bed environment and identify the image (myimage) as the first version for testing a new application before moving it to production. Which of the following commands will accomplish this task?
    1. A. docker build -t myimage:1.0 .
    2. B. docker build -t myimage: .
    3. C. docker build -t myimage-1.0 .
    4. D. docker build -i myimage:1.0 .
    Explanation

    The correct answer is: A. docker build -t myimage:1.0 ..

    The correct answer is A (docker build -t myimage:1.0 .) because docker build creates a Docker image from a Dockerfile, the -t flag tags the image with a name and version (myimage:1.0), and the period (.) specifies the build context as the current directory where the Dockerfile is located. This creates the image with the specified version tag for testing purposes. Option B is missing the version number after the colon. Option C uses a hyphen instead of a colon for the tag, which creates a different tag format.
  2. Question 2

    You are tasked with configuring a continuous integration pipeline using Jenkins for a containerized application. Which plugin is essential for interacting with Docker?
    1. A. Docker Pipeline
    2. B. Kubernetes Plugin
    3. C. GitHub Integration
    4. D. Maven Plugin
    Explanation

    The correct answer is: A. Docker Pipeline.

    For a Jenkins CI/CD pipeline that interacts with Docker (building images, running containers), the Docker Pipeline plugin (A) is essential. Kubernetes Plugin (B) is for Kubernetes deployments; GitHub Integration (C) and Maven Plugin (D) support other aspects. Docker Pipeline enables Jenkins to build and use Docker images in the pipeline.
  3. Question 3

    In a containerized environment, which of the following is a best practice to enhance security?
    1. A. Run containers as root
    2. B. Use a single container for multiple services
    3. C. Use minimal base images
    4. D. Disable container logs
    Explanation

    The correct answer is: C. Use minimal base images.

    Using minimal base images (C) reduces attack surface: fewer packages mean fewer vulnerabilities and a smaller footprint. Running as root (A) and using one container for multiple services (B) violate best practices; disabling logs (D) hinders auditing and troubleshooting. Minimal images (e.g., Alpine, distroless) are a container security best practice.
  4. Question 4

    Which of the following data structures is written in yaml?
    1. A. key: value
    2. B. {key: value}
    3. C. key=value
    4. D. value
    Explanation

    The correct answer is: A. key: value.

    `key: value` is YAML (YAML Aint Markup Language) syntax with key-value pairs using colon separation. Option B is JSON syntax. Option C is configuration file syntax. Option D is XML syntax. making "key: value" the correct answer.
  5. Question 5

    A new application container was built with an incorrect version number. Which of the following commands should be used to rename the image to match the correct version 2.1.2?
    1. A. docker tag comptia/app:2.1.1 comptia/app:2.1.2
    2. B. docker push comptia/app:2.1.1 comptia/app:2.1.2
    3. C. docker rmi comptia/app:2.1.1 comptia/app:2.1.2
    4. D. docker update comptia/app:2.1.1 comptia/app:2.1.2
    Explanation

    The correct answer is: A. docker tag comptia/app:2.1.1 comptia/app:2.1.2.

    The correct answer is A (docker tag comptia/app:2.1.1 comptia/app:2.1.2) because docker tag creates a new tag (alias) for an existing image without duplicating the image data. This allows you to rename or version an image efficiently. The syntax is 'docker tag source-image target-image', where both images share the same underlying layers. Option B (docker push) uploads images to a registry but doesn't rename them locally. Option C (docker rmi) removes images, which is the opposite of what you want.

Other CompTIA Linux+ domains

Practice all 176 Scripting, Containers, and Automation questions · Browse CompTIA Linux+