so, I'm learning and new to Docker and I'm trying to use the docker run
command to run an image that is produced from Visual Studio 2017.
Some background:
The aim is to publish a docker image to a Container Registry (I'm using gitlab), create a docker droplet in DigitalOcean and pull the image and run it.
I am trying to build a release image and run it locally first.
I have a VS solution which contains 3 projects:
- .net core mvc
- .net core library
- .net core api
I have a docker compose file and each project has a docker file. All generated by visual studio using the docker support tool.
I can build and run both in debug and release mode in VS and it runs the image and I can browse to both the web app and api - all is okay.
I have tried to follow the answer to this question:
How to run docker image produced by VS 2017
So I have tried:
docker run --rm -p 80:5000 -d myapp.web:latest
And I have tried both http://localhost:5000
and http://127.0.0.1:5000
in a browser and both cannot be loaded or resolved.
I can see the docker images produced by VS below via the docker images
command
REPOSITORY TAG IMAGE ID CREATED SIZE
myapp.apinet latest b3fa6d92bd23 24 hours ago 305MB
myapp.web latest f418d4571ac3 24 hours ago 315MB
<none> <none> 50c89857daf1 24 hours ago 315MB
If it helps, one of my docker files:
FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app
EXPOSE 80
FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY *.sln ./
COPY src/myapp.Web/myapp.Web.csproj src/myapp.Web/
COPY src/myapp.Core/myapp.Core.csproj src/myapp.Core/
RUN dotnet restore
COPY . .
WORKDIR /src/src/myapp.Web
RUN dotnet build -c Release -o /app
FROM build AS publish
RUN dotnet publish -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "myapp.Web.dll"]
I have also inspected the docker image using docker inspect myapp.web
and port 80 is exposed:
"ExposedPorts": {
"80/tcp": {}
},
I have tried the asp.net core example from https://github.com/dotnet/dotnet-docker/tree/master/samples/aspnetapp as below, and that works fine.
docker run --rm -p 8000:80 --name aspnetcore_sample microsoft/dotnet-samples:aspnetapp
Any suggestions or ideas?