Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

随机端口如何在docker容器中映射? #13

Open
hexxv opened this issue Aug 17, 2023 · 2 comments
Open

随机端口如何在docker容器中映射? #13

hexxv opened this issue Aug 17, 2023 · 2 comments

Comments

@hexxv
Copy link

hexxv commented Aug 17, 2023

server.NewServer() 用到了 xnet.ParseAddr() , 用到了随机端口。
我想问:如果我将项目打包成docker镜像,容器化运行时,如何映射容器与宿主机的端口?

@dobyte
Copy link
Owner

dobyte commented Aug 18, 2023

docker中使用的话,可以改成固定端口

@hexxv
Copy link
Author

hexxv commented Oct 17, 2023

谢谢,我现在知道了。固定端口是一种方式,还有一种就是docker的 host网络模式 也可以

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants