When Docker starts a container, it specifies the access port. You can specify multiple port mappings through multiple -p options. udp will have its own port number in the background, which is different from the port number accessed by the service. At this time, you need to specify it when starting the service. like:
8080 is the port number exposed by the service itself, and 8090 is the port number of the service itself. 10000 is the port number exposed by udp and 11000 is the port listened by udp itself. If it is udp, please pay attention to declare it. Supplementary knowledge: The project in the docker container listens to udp and cannot receive messages When we generate a container and run it, we need to configure the external exposure port. If udp is used, we must also specify the udp port separately. 1.udp sender (ip xxxxxx port: 9200) Create a Dockerfile in the current directory and use it to generate the image docker build -t image name. (Note that the last dot should not be missed, it means directory) Run the generated image docker run -tid --name container name -p 19008:8080 --restart=always image name Note: The sender does not need to expose the port. It can be understood that the sender does not need to use the port of the machine. It is just that when sending, the information contains the IP and port of the target host. 2.UDP receiving end Create a Dockerfile in the current directory and use it to generate the image docker build -t image name. (Same as above) Run the generated image docker run -tid --name container name -p 19008:8080 -p 9200:9200/udp --restart=always image name Note: The receiving end needs to expose the port. It can be understood that the receiving end needs to listen to the port of the local machine, but the corresponding port of the host machine cannot be listened to in the container. For example, the udp information sent in 1 corresponds to the host port 9200, but if the udp receiving end in the container in 2 wants to listen to the host port 9200, it must map the 9200 in the container to the 9200 of the host. Result: After the above configuration, the udp message was successfully received The above article on solving the problem of specifying udp port number in docker is all the content that the editor shares with you. I hope it can give you a reference, and I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Application of mapState idea in vuex
>>: html+css+js to realize the function of photo preview and upload picture
This article example shares the specific code of ...
Now most projects have begun to be deployed on Do...
A simple Linux guessing game source code Game rul...
Preface Although some love in this world has a pr...
Preface In a relatively complex large system, if ...
Table of contents 1 What is function currying? 2 ...
I have a product parts table like this: part part...
1. What is a two-column layout? There are two typ...
The installation tutorial of mysql 8.0.20 winx64....
Including the use of check boxes and radio buttons...
Table of contents Docker Compose usage scenarios ...
User namespace is a new namespace added in Linux ...
I recently bought a Tencent Cloud server and buil...
Install Docker on CentOS 8 Official documentation...