The EXPOSE instruction

The EXPOSE instruction opens up a container network port for communicating between the container and the external world.

The syntax of the EXPOSE instruction is as follows:

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

Here, the code terms mean the following:

  • <port>: This is the network port that has to be exposed to the outside world.
  • <proto>: This is an optional field provided for a specific transport protocol, such as TCP and UDP. If no transport protocol has been specified, then TCP is assumed to be the transport protocol.

The EXPOSE instruction allows you to specify multiple ports in a single line.

The following is an example of the EXPOSE instruction inside a Dockerfile exposing the 7373 port number as a UDP port and the 8080 port number as a TCP port. As mentioned earlier, if the transport protocol has not been specified, then the TCP transport is assumed to be the transport protocol:

EXPOSE 7373/udp 8080 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset