tl;dr summary of the problem:
To troubleshoot I have created the simplest possible application to run in a dockers container, an F# / Suave application like so:
open Suave
[<EntryPoint>]
let main args =
startWebServer defaultConfig (Successful.OK "Hello World!")
0
Which works fine, returning a simple "Hello World!" when I run it locally.
To containerize the app I have followed the instructions at " Dockerize a .NET Core application " which instructs me to run the container like
$ docker run -d -p 8080:80 --name myapp aspnetapp
I cannot connect to the "website" at http://localhost:80 nor http://localhost:8080 , which apparently is a common problems for Docker users running Windows. However the solution that seems to have fixed this problem for every other Windows user on the internet, running
docker inspect myapp
and then hitting the resulting IPAddress, does not work either. I get:
Hitting both http://172.17.0.2:80 and http://172.17.0.2:8080 in Chrome gives me "Site can't be reached."
Also worth noting, when I run
docker logs myapp
The only line is
[17:43:21 INF] Smooth! Suave listener started in 73.476ms with binding 127.0.0.1:8080
As a guess, I have also tried
ipconfig
and then hitting the IP address of the Docker NAT adapter, but this also results in an unreachable site.
UPDATE :
Another observation which might or might not be relevant: Many online tutorials suggest that under Windows you need to directly connect to the IP Address of the container, and to get that IP address by running
docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" myapp
which for me, always yields:
When I run a vanilla
docker inspect myapp
the resulting JSON is not structured exactly like the recommended query. I get a bridge node, but no nat node:
您的应用程序说它绑定到localhost:8080,但是您正在发布端口80。停止容器,然后使用以下命令重新运行:
docker run -d -p 8080:8080 --name myapp aspnetapp
Try adding the following lines in docker file
ENV ASPNETCORE_URLS http://+:80
EXPOSE 80
Reference: https://www.sep.com/sep-blog/2017/02/20/hosting-asp-net-core-docker/
我的容器化应用需要侦听/绑定到0.0.0.0,而不是127.0.0.1。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.