Dockerizing ASP.NET applications MCQs ASP.NET

What is the primary purpose of Docker in ASP.NET applications? A. To manage databases B. To containerize applications for consistent deployment C. To compile code D. To handle HTTP requests Answer: B Which file defines the Docker image configuration for an ASP.NET application? A. Dockerfile B. docker-compose.yml C. appsettings.json D. web.config Answer: A What is the role of the ENTRYPOINT instruction in a Dockerfile? A. To specify the command to run when the container starts B. To define environment variables C. To copy files into the container D. To expose ports Answer: A Which Docker command is used to build an image from a Dockerfile? A. docker build B. docker run C. docker create D. docker pull Answer: A How can you run an ASP.NET application in a Docker container? A. Use docker run to start a container from the image B. Use docker build C. Use docker-compose D. Use docker exec Answer: A What does the EXPOSE instruction in a Dockerfile do? A. Defines the ports that the container listens on B. Copies files into the container C. Sets environment variables D. Specifies the base image Answer: A Which command is used to view the running Docker containers? A. docker ps B. docker list C. docker images D. docker status Answer: A What is the purpose of the docker-compose.yml file? A. To define and run multi-container Docker applications B. To configure environment variables C. To build Docker images D. To run individual containers Answer: A How can you remove an unused Docker image? A. docker rmi B. docker rm C. docker delete D. docker stop Answer: A Which base image is commonly used for ASP.NET Core applications in Docker? A. mcr.microsoft.com/dotnet/aspnet B. ubuntu C. alpine D. mcr.microsoft.com/dotnet/sdk Answer: A How can you persist data across Docker container restarts? A. Use Docker volumes B. Use Docker networks C. Use Docker secrets D. Use docker exec Answer: A What does the docker run command do? A. It creates and starts a new container B. It builds a Docker image C. It removes a container D. It lists all images Answer: A How can you share environment variables between Docker containers? A. Use Docker Compose and define them in docker-compose.yml B. Set them in the Dockerfile C. Use the docker run command with -e options D. All of the above Answer: D What is a Docker volume used for? A. To persist and manage data in containers B. To define the container’s network C. To build Docker images D. To set container environment variables Answer: A Which Docker command is used to stop a running container? A. docker stop B. docker pause C. docker kill D. docker halt Answer: A What is the purpose of the docker-compose up command? A. To start up all services defined in docker-compose.yml B. To build Docker images C. To remove stopped containers D. To view container logs Answer: A What is the purpose of the docker build command? A. To create a Docker image from a Dockerfile B. To start a Docker container C. To list Docker images D. To remove unused images Answer: A Which Dockerfile instruction sets the working directory inside the container? A. WORKDIR B. CMD C. RUN D. VOLUME Answer: A How can you view the logs of a running Docker container? A. docker logs B. docker inspect C. docker ps D. docker status Answer: A Which command can be used to build and run multi-container Docker applications? A. docker-compose B. docker run C. docker build D. docker exec Answer: A How do you remove all stopped containers in Docker? A. docker container prune B. docker rm -f C. docker stop all D. docker delete Answer: A What does the CMD instruction in a Dockerfile do? A. Specifies the default command to run when the container starts B. Sets environment variables C. Exposes ports D. Copies files into the container Answer: A Which file format is used for defining services in Docker Compose? A. YAML B. JSON C. XML D. TOML Answer: A How can you scale Docker services defined in a docker-compose.yml file? A. Use the docker-compose scale command B. Modify the docker-compose.yml file to set the number of replicas C. Use the docker run command with --scale D. Use Docker Swarm Answer: B What is a Docker image? A. A read-only template used to create Docker containers B. A running instance of a container C. A file system snapshot D. A volume for data persistence Answer: A What is the purpose of the docker network command? A. To manage Docker networks B. To create Docker volumes C. To build Docker images D. To remove Docker containers Answer: A How can you update a Docker image? A. Use docker pull to get the latest version from a repository B. Edit the Dockerfile and rebuild the image C. Use docker build with updated instructions D. All of the above Answer: D How can you debug a Docker container? A. Use docker exec to start an interactive shell B. Use docker logs to view logs C. Attach a debugger to the container D. All of the above Answer: D Which Docker command is used to create a Docker network? A. docker network create B. docker create network C. docker network add D. docker network new Answer: A What is a Docker secret? A. A secure way to manage sensitive data like passwords B. A special type of Docker container C. A hidden image repository D. An encrypted volume Answer: A How can you restrict a Docker container’s CPU and memory usage? A. Use the --memory and --cpus options with docker run B. Set limits in the Dockerfile C. Modify the docker-compose.yml file D. Both A and C Answer: D What does the docker-compose down command do? A. Stops and removes all containers defined in the docker-compose.yml B. Builds Docker images C. Lists running containers D. Pauses Docker containers Answer: A How can you ensure that an ASP.NET Core application uses a specific port when running in Docker? A. Set the ASPNETCORE_URLS environment variable B. Modify the Dockerfile to expose the port C. Change the port in appsettings.json D. Use the --port option with docker run Answer: A Which Docker command is used to view detailed information about a container? A. docker inspect B. docker info C. docker details D. docker status Answer: A How can you handle application configuration in a Dockerized ASP.NET Core app? A. Use environment variables B. Modify appsettings.json inside the container C. Use Docker secrets D. Both A and C Answer: D What is the purpose of the docker-compose build command? A. To build or rebuild Docker images defined in docker-compose.yml B. To start the Docker containers C. To stop Docker containers D. To remove Docker images Answer: A How do you add a health check to a Docker container? A. Use the HEALTHCHECK instruction in the Dockerfile B. Configure health checks in docker-compose.yml C. Use Docker Swarm for health management D. Add a health check in appsettings.json Answer: A What is the purpose of the docker tag command? A. To create a new tag for an image B. To build Docker images C. To push images to a repository D. To run a Docker container Answer: A Which of the following is a common best practice when Dockerizing ASP.NET Core applications? A. Use a multi-stage build to keep the final image small B. Expose all ports in the Dockerfile C. Run the container as the root user D. Include sensitive data directly in the Dockerfile Answer: A How can you remove all unused Docker images and containers? A. Use docker system prune B. Use docker clean C. Use docker rm -f D. Use docker remove Answer: A What is the purpose of the .dockerignore file? A. To exclude files and directories from being added to the Docker image B. To specify environment variables C. To define Docker network settings D. To set image tags Answer: A How can you deploy a Dockerized ASP.NET application to a Kubernetes cluster? A. Create Kubernetes deployment files and apply them with kubectl B. Use Docker Swarm C. Deploy directly from Docker Compose D. Use the docker deploy command Answer: A Which Docker command can be used to remove a stopped container? A. docker rm B. docker stop C. docker delete D. docker kill Answer: A What is a Docker container? A. A lightweight, standalone, and executable package that includes everything needed to run an application B. A virtual machine C. A storage volume D. A network configuration Answer: A How do you ensure that Docker containers run with the latest updates? A. Regularly rebuild and redeploy Docker images B. Update the container manually C. Use the docker update command D. Modify the Dockerfile only Answer: A What is the purpose of the VOLUME instruction in a Dockerfile? A. To create a mount point with the specified path and mark it as holding externally mounted volumes from native host or other containers B. To expose ports C. To copy files into the container D. To set environment variables Answer: A How do you check the version of Docker installed on your system? A. docker --version B. docker version C. docker info D. docker status Answer: B What is a multi-stage build in Docker? A. A process that uses multiple FROM statements to build an image in stages, resulting in smaller final images B. A way to deploy multiple Docker containers C. A method for managing Docker networks D. A feature for scaling containers Answer: A Which Docker command helps you to see the file system of a running container? A. docker exec -it <container_id> /bin/sh B. docker inspect C. docker files D. docker container fs Answer: A What does the docker push command do? A. Pushes a Docker image to a repository B. Runs a Docker container C. Builds a Docker image D. Stops a Docker container Answer: A How can you make Docker logs easier to manage for a large application? A. Use a logging driver to send logs to an external system B. Log to the console C. Save logs to a file inside the container D. Ignore logging Answer: A What does the docker-compose logs command do? A. Displays logs for services defined in docker-compose.yml B. Starts Docker containers C. Builds Docker images D. Lists all Docker images Answer: A Which Docker feature allows you to manage container configurations and secrets securely? A. Docker secrets B. Docker volumes C. Docker networks D. Docker environment variables Answer: A How do you specify a different environment for a Dockerized ASP.NET application? A. Set the ASPNETCORE_ENVIRONMENT environment variable in the Dockerfile or docker-compose.yml B. Modify the Dockerfile to include environment settings C. Change settings directly in the application code D. Use docker run with --env option Answer: A What is the primary benefit of using Docker for development and deployment? A. Consistency across different environments B. Faster code compilation C. Better performance of the application D. Easier code management Answer: A How can you create a Docker image for an ASP.NET Core application? A. Write a Dockerfile and use docker build B. Use Visual Studio’s built-in Docker support C. Use docker-compose to build the image D. Both A and B Answer: D Which Docker command is used to create a new container from an image? A. docker create B. docker run C. docker start D. docker init Answer: B What is the purpose of the USER instruction in a Dockerfile? A. To set the user that the container runs as B. To create a new Docker image C. To copy files into the container D. To expose ports Answer: A How can you restrict network access to a Docker container? A. Use Docker network settings and firewall rules B. Configure network settings in docker-compose.yml C. Use --network options with docker run D. All of the above Answer: D What is a Docker swarm? A. A mode for Docker that provides clustering and orchestration of Docker containers B. A type of Docker container C. A volume for storing data D. A logging driver Answer: A How do you test Docker images locally before deploying them? A. Use docker run to test the image in a local container B. Use docker build C. Deploy the image to a remote server D. Push the image to a repository Answer: A What is the role of Docker Hub? A. A public registry for Docker images B. A tool for managing Docker containers C. A logging system for Docker containers D. A Docker configuration file Answer: A How can you ensure that a Docker container has access to a specific directory on the host system? A. Use Docker volumes to mount the host directory into the container B. Set permissions in the Dockerfile C. Use the --mount option with docker run D. Both A and C Answer: D What is the use of the docker-compose down command? A. To stop and remove all containers defined in the docker-compose.yml B. To build Docker images C. To start Docker containers D. To view container logs Answer: A
All Copyrights Reserved 2025 Reserved by T4Tutorials