Apache Web Server Essentials with Docker u0026 Containers Quiz

Explore foundational concepts of running Apache in containerized environments using Docker, including configuration, basic commands, and best practices for web server deployment. This quiz is designed for those new to containers, highlighting key steps and terminology in modern web service hosting.

  1. Running Apache with Docker

    Which Docker command would you use to start an Apache web server in a new detached container?

    1. docker build -t apache
    2. docker pull apache
    3. docker stop apache
    4. docker run -d httpd

    Explanation: The command 'docker run -d httpd' runs an Apache container in detached mode. 'docker pull apache' downloads an image but does not start a container. 'docker build -t apache' is used to build a container image, not to run it. 'docker stop apache' stops a running container rather than starting one.

  2. Exposing Ports for Apache

    When running Apache in a Docker container, which flag allows you to map the container's port 80 to port 8080 on your host?

    1. -m 8080:80
    2. -e 8080:80
    3. -p 8080:80
    4. -v 8080:80

    Explanation: The '-p 8080:80' flag is used to map port 80 in the container to port 8080 on the host. '-v' is for volume mapping, not networking. '-e' sets environment variables. '-m' sets memory limits, so these options do not handle port mapping.

  3. Understanding Volumes

    Which Docker option would you use to ensure your Apache container uses a local directory for its web content files?

    1. -v /local/path:/usr/local/apache2/htdocs
    2. -d /local/path:/usr/local/apache2/htdocs
    3. -e /local/path:/usr/local/apache2/htdocs
    4. -p /local/path:/usr/local/apache2/htdocs

    Explanation: The '-v' flag creates a volume mapping so the container uses files from the host directory. '-p' is used for port forwarding, not file sharing. '-e' is intended for setting environment variables, and '-d' runs the container in detached mode but does not assign directories.

  4. Default Apache Directory

    What is the default directory used by Apache to serve web pages inside a typical container?

    1. /usr/local/apache2/htdocs
    2. /etc/apache2/conf
    3. /var/www/html
    4. /home/apache

    Explanation: Inside standard containers, Apache commonly uses '/usr/local/apache2/htdocs' as the root directory for web files. '/var/www/html' is typical in some environments, but not the default in most containers. '/etc/apache2/conf' holds configuration files, not web content. '/home/apache' is not a standard directory for web files.

  5. Checking Apache Container Status

    Which command shows you if your Apache Docker container is running?

    1. docker rm apache
    2. docker ps
    3. docker commit apache
    4. docker logs apache

    Explanation: 'docker ps' lists all currently running containers, helping you confirm if the Apache container is active. 'docker logs apache' displays container logs but not status directly. 'docker rm apache' removes a container, and 'docker commit apache' saves its state, neither of which checks running status.

  6. Editing Apache Configuration

    If you need to update settings in Apache's main configuration file within a Docker container, which file should you typically edit?

    1. httpd.conf
    2. config.json
    3. index.html
    4. apache.ini

    Explanation: 'httpd.conf' is the main configuration file for Apache, used for changing server settings. 'index.html' is a web page, not a configuration file. 'config.json' and 'apache.ini' are not standard Apache configuration files, making them incorrect.

  7. Building a Custom Apache Image

    Which file is used for specifying instructions to build a custom Docker image that includes Apache?

    1. compose.yaml
    2. Makefile
    3. build.xml
    4. Dockerfile

    Explanation: A 'Dockerfile' contains build instructions for custom Docker images, including installing Apache. 'Makefile' is used by build automation tools and not for containers. 'build.xml' relates to other build systems, and 'compose.yaml' configures multiple services, not image building steps.

  8. Accessing the Running Apache Container

    Which command lets you access a shell inside a running Apache Docker container named 'webserver'?

    1. docker attach webserver
    2. docker enter webserver /sh
    3. docker exec -it webserver /bin/bash
    4. docker connect webserver

    Explanation: 'docker exec -it webserver /bin/bash' opens an interactive shell inside the container. 'docker connect' is not a valid Docker command. 'docker attach webserver' displays the container’s primary process output but doesn't start a shell. 'docker enter' is not standard for direct shell access.

  9. Stopping an Apache Container

    What is the correct command to gracefully stop a running Apache container named 'myapache'?

    1. docker remove myapache
    2. docker stop myapache
    3. docker pause myapache
    4. docker kill myapache

    Explanation: 'docker stop myapache' halts the running container elegantly, allowing processes to shut down cleanly. 'docker pause' only suspends the container. 'docker kill' forcefully ends it with less grace, while 'docker remove' (or 'rm') deletes the container but does not stop it.

  10. Purpose of Docker Compose

    What is the primary purpose of using Docker Compose with Apache containers?

    1. To build Docker images from scratch
    2. To define and manage multi-container applications
    3. To create new network adapters on the host
    4. To increase Apache's speed automatically

    Explanation: Docker Compose helps define and run applications with multiple containers, such as Apache with a database in a single configuration file. It does not make Apache inherently faster. It is used for orchestration, not building images or network adapters.