Complete the code to run a container with a custom network for DNS-based service discovery.
docker network create my_network
docker run --rm -d --name webapp --network [1] nginxUsing --network my_network connects the container to the custom network my_network, enabling DNS-based service discovery within that network.
Complete the command to run a second container that can reach the first container by its name using Docker DNS.
docker run --rm -it --network my_network busybox ping [1]Using the container name webapp allows the second container to resolve and ping the first container via Docker's internal DNS on the same network.
Fix the error in the Docker Compose service definition to enable service discovery by service name.
version: '3' services: app: image: myapp networks: - [1] networks: mynet: driver: bridge
The service must be connected to the defined network mynet to enable DNS-based service discovery within that network.
Fill both blanks to create a Docker Compose file that defines two services communicating via service names on a custom network.
version: '3' services: frontend: image: frontend_image networks: - [1] backend: image: backend_image networks: - [2] networks: appnet: driver: bridge
Both services must be connected to the same custom network appnet to communicate using service names.
Fill all three blanks to create a Docker Compose snippet that uses environment variables to configure the backend service URL for the frontend service.
version: '3' services: frontend: image: frontend_image environment: - BACKEND_URL=http://[1]:[2] networks: - [3] backend: image: backend_image networks: - appnet networks: appnet: driver: bridge
The frontend uses the service name backend and port 8080 to reach the backend. Both services are on the appnet network for DNS resolution.