Home > database >  What is the syntax of the Dockerfile EXPOSE Command?
What is the syntax of the Dockerfile EXPOSE Command?

Time:12-23

Reading the docker documentation at https://docs.docker.com/engine/reference/builder/#expose the expose command syntax is described as:

EXPOSE <port> [<port>/<protocol>...]

To me, this indicates that I can use it like:

EXPOSE 8080
EXPOSE 8080 8081/tcp 8082/udp

but not

EXPOSE 8080/tcp

The examples they give contradict this:

EXPOSE 80/udp

and to expose the same port on different protocols they suggest using two lines:

EXPOSE 80/tcp
EXPOSE 80/udp

What does the syntax description actually mean? Does EXPOSE 8080 8081 expose two ports? Is EXPOSE 80/tcp 80/udp illegal?

CodePudding user response:

The syntax is actually something like

"EXPOSE ", { p };

where

p = port, [ "/", proto ], " ";

(in EBNF)

Does EXPOSE 8080 8081 expose two ports?

Yes

Is EXPOSE 80/tcp 80/udp illegal?

No

  • Related