英文:
Run a Go Server on Codenvy Environment
问题
我正在尝试使用Codenvy开发Go服务器应用程序,但我不知道如何运行。我已经创建了项目并选择了Web Go运行环境。但是当我运行它时,项目在我定义的不同URL端口上运行。
有没有办法不使用http端口而使用动态端口?
http.ListenAndServe("{get_url_port}", nil)
而是
http.ListenAndServe(":8080", nil)
英文:
I'm trying to use Codenvy to develop Go server apps, but I don't know how to run.
I have already created the project and choose the Web Go runner environment.
But when I run it, the project run in a different URL port that I have defined.
Have some way to not use an http port an use a dynamic port?
<!-- language: go -->
http.ListenAndServe("{get_url_port}", nil)
>instead
http.ListenAndServe(":8080", nil)
答案1
得分: 1
该过程在一个容器中运行,并且每次应用程序启动时,端口8080都会映射到一个随机端口。因此,每次都是不同的端口。然而,内部端口是相同的,因为应用程序在Docker容器中运行。
你能详细说明并提供更多细节吗?
英文:
The process runs in a container, and port 8080 is mapped to a random port each time the app start. So, it's a different port each time. However, the same internal port - as the app runs in a Docker container.
Can you elaborate and give more details?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论