Command:
docker run -it -p localport:containerport --rm <containerTag>
Example:
docker run -it -p 8080:80 --rm dotnet-diag-webapi-example:latest
Quick points: Expose container 80 as local 8080, using --rm to delete the container once the process is terminated.
Dockerize a local publish:
- Run
dotnet publish -c Release
- Build the image by copying the content of
publish
folder:
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /app
COPY ./bin/Release/net7.0/publish .
ENTRYPOINT ["dotnet", "WebAPIExample.dll"]