Being new to Docker, I have a basic question on why Docker uses the port numbers ranging from 32768 to 65535 ?
Why is that particular range selection ? Are other ports not useful ?
Can someone help me in understanding this better..
The highest TCP port number is 65,535. The TCP protocol provides 16 bits for the port number, and this is interpreted as an unsigned integer; all values are valid, apart from 0, and so the largest port number is (2^16 - 1) or 65,535.
The default ephemeral port range from 49153 through 65535 is always used for Docker versions before 1.6.
Port mapping is used to access the services running inside a Docker container. We open a host port to give us access to a corresponding open port inside the Docker container. Then all the requests that are made to the host port can be redirected into the Docker container.
Ports is defined as: Either specify both ports (HOST:CONTAINER), or just the container port (a random host port will be chosen). Ports mentioned in docker-compose. yml will be shared among different services started by the docker-compose. Ports will be exposed to the host machine to a random port or a given port.
Short answer: These ports were once defined for being not to be reserved for some special use like 80 or 443.
Long anwser: Best TCP port number range for internal applications
The port numbers in the range from 0 to 1023 are the system ports. These are used for standard, well-known network services. They are also restricted, so only the super user is able to bind to one of these.
Next ranges of ports, especially under 10000, are still usually a standard ports of some services, but they are not restricted. Some common examples are 8080 (HTTP alternative), 8443 (HTTPS alternative) or 1099 (Java RMI registry). See this for more examples.
Range of 32768 to 65535 is quite safe to just get a random one and use, because they are not used widely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With