DCA · Question #88
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/udp dns-cache'
The correct answer is A. Yes. The docker service create command with -p 53:53/udp correctly publishes port 53 for the service using only the UDP protocol.
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/udp dns-cache'
Options
- AYes
- BNo
How the community answered
(32 responses)- A94% (30)
- B6% (2)
Why each option
The `docker service create` command with `-p 53:53/udp` correctly publishes port 53 for the service using only the UDP protocol.
The `docker service create` command's `-p` or `--publish` flag syntax allows specifying the protocol (TCP or UDP) in the format `published_port:target_port/protocol`. By using `53:53/udp`, the command explicitly configures the service to expose port 53 on the swarm overlay network using only the UDP protocol.
The `-p` flag syntax `published_port:target_port/protocol` is the standard and correct way to specify a port and its associated protocol (UDP or TCP) when publishing a Docker Swarm service port.
Concept tested: Docker Swarm service port publishing
Source: https://docs.docker.com/engine/reference/commandline/service_create/#publish-ports--p
Topics
Community Discussion
No community discussion yet for this question.