ScanSkill

EXPOSE

The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime. i.e, It helps in inter-container communication. You can specify whether the port listens on TCP or UDP, and the default is TCP.

Syntax

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

Example

EXPOSE 80
EXPOSE 80/udp
EXPOSE 80/tcp

Note: To use both TCP and UDP, you need to include two instructions.

But if you want to bind the port of the container with the host machine on which the container is running, use -p option of docker run command.

docker run -p <HOST_PORT>:<CONTAINER:PORT> IMAGE_NAME
docker run -p 80:80/udp myDocker