dongtangu8403 2018-12-30 18:34
浏览 64
已采纳

Revel和Docker容器

I am attempting to create a docker container that contains the revel skeleton app. Everything seems to build OK and the container is created but when I go to localhost:9000 in my browser nothing comes up.
To make sure my environment is working properly I created a simple hello world go app and created a docker container for it. It worked OK using the same port 9000. This makes me think that there is something not configured properly in my dockerfile.

Dockerfile:

#Compile stage
FROM golang:1.11.4-alpine3.8 AS build-env
ENV CGO_ENABLED 0
RUN apk add --no-cache git
ADD . /go/src/revelapp

# Install revel framework
RUN go get -u github.com/revel/revel
RUN go get -u github.com/revel/cmd/revel
#build revel app
RUN revel build revelapp app dev

# Final stage
FROM alpine:3.8
EXPOSE 9000
WORKDIR /
COPY --from=build-env /go/app /
ENTRYPOINT /run.sh

Docker command used:

docker build -t revelapp . && docker run -p 9000:9000 --name revelapp revelapp 

After command is executed and container is created the console shows:

INFO  17:25:01    app     run.go:32: Running revel server                      
INFO  17:25:01    app   plugin.go:9: Go to /@tests to run the tests.           
Revel engine is listening on.. localhost:9000

When I go to localhost:9000 I would expect to see the text It Works!

  • 写回答

1条回答 默认 最新

  • douche1936 2018-12-30 18:40
    关注

    You're listening on localhost:9000, so 127.0.0.1 points to your container and not your local machine.

    You have two solutions to make it work:

    • Listen on 0.0.0.0:9000
    • Use --network="host" in your docker run command: 127.0.0.1 in your docker container will point to your docker host.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料