Exposing ASP.NET Core Port via Docker
Hi,
I am having some problems exposing a ASP.NET Core project which I have deployed to a docker container. These are the steps I took and I was wondering if anyone could point out what I have done wrong.
- Created a Dockerfile and exposed port 5000:
FROM microsoft/dotnet:latest COPY . /app WORKDIR /app # Install netstat RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y \ net-tools \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Restore and Build. RUN ["dotnet", "restore"] RUN ["dotnet", "build"] # Container will open port 5000 allowing us to connect to it. EXPOSE 5000 # Start the dotnet application on port 5000. CMD ["dotnet", "run", "--server.urls", "http://localhost:5000"]
-
Build the Image
docker build -t test .
This builds the image successfully and I can see that it exists when I run docker images
-
Run the Container
docker run -d -p 5000:5000 test
Now when I go to http://localhost:5000/ I get a ERR_EMPTY_RESPONSE. I have also tried to look inside the container to see if the service is running. When I do a netstat within the container I can see that the service seems to be listening:
docker exec c908 netstat -l Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 localhost:5000 0.0.0.0:* LISTEN
I also am able to curl the service from within the container docker exec c908 curl localhost:5000 which matches what I expect to see when accessing outside the container.
Any help would be appreciated. I am working on a Mac machine if that makes any difference.
Thanks!
0 comments:
Post a Comment