DCA · Question #89
Does this command create a swarm service that only listens on port 53 using the UDP protocol? Solution: `docker service create -name dns-cache -p 53:53 -service udp dns-cache'
The correct answer is B. No. The command provided incorrectly specifies the service name and uses an invalid flag for protocol, thus it would fail to create a service listening on port 53 using UDP.
Question
Does this command create a swarm service that only listens on port 53 using the UDP protocol? Solution: `docker service create -name dns-cache -p 53:53 -service udp dns-cache'
Options
- AYes
- BNo
How the community answered
(27 responses)- A22% (6)
- B78% (21)
Why each option
The command provided incorrectly specifies the service name and uses an invalid flag for protocol, thus it would fail to create a service listening on port 53 using UDP.
The command contains syntactical errors, specifically using `-name` instead of `--name` and an unrecognized `-service udp` flag, which means it will not execute successfully to create a UDP-only service.
The command uses `-name` instead of `--name` (a single dash is typically for single-letter options), which would cause an error. More critically, the `-service udp` flag is not a valid or recognized option for `docker service create` to specify the protocol for port mapping; the correct way is within the `-p` flag's syntax, like `53:53/udp`.
Concept tested: Docker Swarm service creation syntax
Source: https://docs.docker.com/engine/reference/commandline/service_create/#publish-ports--p
Topics
Community Discussion
No community discussion yet for this question.