nerdexam
Docker

DCA · Question #17

Which of the following commands will create a swarm service which only listens on port 53 using the UDP protocol?

The correct answer is A. docker service create --name dns-cache -p 53:53/udp dns-cache. To create a Docker Swarm service that exposes a specific port using the UDP protocol, the --publish (or -p) flag must specify the protocol with /udp.

Submitted by helene.fr· Apr 18, 2026Container Orchestration

Question

Which of the following commands will create a swarm service which only listens on port 53 using the UDP protocol?

Options

  • Adocker service create --name dns-cache -p 53:53/udp dns-cache
  • Bdocker service create --name dns-cache -p 53:53 --service udp dns-cache
  • Cdocker service create --name dns-cache -p 53:53 ..constraint networking.protocol.udp=true dns-
  • Ddocker service create --name dns-cache -p 53:53 --udp dns-cache

How the community answered

(55 responses)
  • A
    89% (49)
  • B
    4% (2)
  • C
    2% (1)
  • D
    5% (3)

Why each option

To create a Docker Swarm service that exposes a specific port using the UDP protocol, the `--publish` (or `-p`) flag must specify the protocol with `/udp`.

Adocker service create --name dns-cache -p 53:53/udp dns-cacheCorrect

The `--publish` (or `-p`) flag in `docker service create` allows specifying the protocol (TCP or UDP) along with the port mapping. Using `-p 53:53/udp` correctly maps host port 53 to container port 53, explicitly for UDP traffic.

Bdocker service create --name dns-cache -p 53:53 --service udp dns-cache

There is no `--service udp` option for `docker service create` to specify the network protocol.

Cdocker service create --name dns-cache -p 53:53 ..constraint networking.protocol.udp=true dns-

While constraints are used for service placement, `networking.protocol.udp=true` is not a valid constraint for specifying the protocol of the published port.

Ddocker service create --name dns-cache -p 53:53 --udp dns-cache

There is no `--udp` option for `docker service create` to specify the network protocol for port publishing.

Concept tested: Docker Swarm service port publishing UDP

Source: https://docs.docker.com/engine/reference/commandline/service_create/#publish-ports--p

Topics

#Docker Swarm#Service Creation#Port Publishing#UDP Protocol

Community Discussion

No community discussion yet for this question.

Full DCA Practice