nerdexam
Cisco

300-910 · Question #105

Refer to the exhibit. A DevOps engineer is deploying a stack of services with Docker Compose. A containerized application running in the app Docker container must communicate with the web-server Docke

The correct answer is C. The application running in the app Docker container will use DNS to resolve the SERVER_NAME environment variable that contains web-server to an IP address.. In a Docker Compose setup, containers within the same network can communicate using their service names as hostnames, so the application in the 'app' container will resolve 'web-server' to an IP address via DNS to connect to the NGINX server.

Containerization

Question

Refer to the exhibit. A DevOps engineer is deploying a stack of services with Docker Compose. A containerized application running in the app Docker container must communicate with the web-server Docker container running a NGINX web server. How must communication between the two Docker containers be configured?
version: "3.3"
services:
 app:
 build: .
 environment:
 SERVER_NAME: web-server
 depends_on:
 - web-server
 web-server:
 image: nginx

Options

  • ADocker containers are completely isolated from each other, so the two Docker containers will not communicate with each other.
  • BDocker Compose will use the depends_on configuration to provide the app Docker container with the IP address of the web-server Docker container.
  • CThe application running in the app Docker container will use DNS to resolve the SERVER_NAME environment variable that contains web-server to an IP address.
  • DThe application running in the app Docker container will use ARP to resolve the SERVER_NAME environment variable that contains web-server to an IP address.

How the community answered

(24 responses)
  • A
    4% (1)
  • B
    4% (1)
  • C
    92% (22)

Why each option

In a Docker Compose setup, containers within the same network can communicate using their service names as hostnames, so the application in the 'app' container will resolve 'web-server' to an IP address via DNS to connect to the NGINX server.

ADocker containers are completely isolated from each other, so the two Docker containers will not communicate with each other.

Docker containers within the same Docker Compose network are explicitly designed to communicate with each other, contradicting the statement that they are completely isolated and cannot communicate.

BDocker Compose will use the depends_on configuration to provide the app Docker container with the IP address of the web-server Docker container.

The 'depends_on' configuration in Docker Compose only ensures that 'web-server' is started before 'app'; it does not inject IP addresses directly into environment variables or handle network resolution for the application.

CThe application running in the app Docker container will use DNS to resolve the SERVER_NAME environment variable that contains web-server to an IP address.Correct

When Docker Compose creates services, it also sets up a default network for these services. Within this network, each service name (like 'web-server') acts as a hostname that can be resolved by other containers in the same network through Docker's embedded DNS service. Therefore, the application in the 'app' container can use the value 'web-server' from the 'SERVER_NAME' environment variable to look up the IP address of the 'web-server' container via DNS and establish communication.

DThe application running in the app Docker container will use ARP to resolve the SERVER_NAME environment variable that contains web-server to an IP address.

ARP (Address Resolution Protocol) maps IP addresses to MAC addresses within a local network segment, which is a lower-level network protocol and not how applications within Docker containers typically resolve service names to IP addresses for inter-container communication.

Concept tested: Docker Compose inter-container networking & DNS

Source: https://docs.docker.com/compose/networking/

Topics

#Docker Compose#Container Networking#Service Discovery#DNS

Community Discussion

No community discussion yet for this question.

Full 300-910 Practice