DCA practice question 1 of 25

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’

Full set: 191 questions
Answer options
A: Yes
B: No Correct answer
Correct Answer:
B. No
Explanation

The command is syntactically incorrect and will not achieve the desired outcome. The --publish or -p flag defaults to the TCP protocol. To specify the UDP protocol, the /udp suffix must be appended directly to the port mapping. The provided command uses -p 53:53, which implies TCP, and then adds a standalone -udp flag, which is not a valid flag for the docker service create command. This will result in a command-line error or unexpected behavior, but not a UDP-only service.

Why Incorrect

A. The command uses an invalid flag (-udp) and fails to use the correct syntax (-p 53:53/udp) to specify the UDP protocol for the port mapping.

References

1. Docker Docs, docker service create command reference. The --publish flag section details the syntax. It states, "By default, the docker service create command publishes ports on the TCP protocol. To publish a port on the UDP protocol, add a /udp suffix to the port number." (https://docs.docker.com/engine/reference/commandline/servicecreate/#publish-service-ports-externally-to-the-swarm--p---publish)

2. Docker Docs, Swarm mode tutorial, "Open a port on a swarm". This guide shows the correct syntax for publishing ports, including the /udp suffix for UDP ports. (https://docs.docker.com/engine/swarm/swarm-tutorial/open-service-port/)

Scroll to Top