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.
Which Docker command would you use to start an Apache web server in a new detached container?
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.
When running Apache in a Docker container, which flag allows you to map the container's port 80 to port 8080 on your host?
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.
Which Docker option would you use to ensure your Apache container uses a local directory for its web content files?
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.
What is the default directory used by Apache to serve web pages inside a typical container?
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.
Which command shows you if your Apache Docker container is running?
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.
If you need to update settings in Apache's main configuration file within a Docker container, which file should you typically edit?
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.
Which file is used for specifying instructions to build a custom Docker image that includes Apache?
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.
Which command lets you access a shell inside a running Apache Docker container named '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.
What is the correct command to gracefully stop a running Apache container named '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.
What is the primary purpose of using Docker Compose with Apache containers?
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.