If creating a new project, then Enable docker support during project creation
OR
- Create a file in the project root called
Dockerfile(no extension) - Inside the file
1
2
3
4
5
6
7
8
9
10
FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /build
COPY . .
RUN dotnet restore
RUN dotnet publish -c Release -o output
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build /build/output .
ENTRYPOINT ["dotnet", "ConferenceApp.dll"]
To build image (from project root)
1
docker build -t conference/api .
To remove the image
1
docker system prune
1
2
3
4
* All Stopped containers
* All networks not used by at least one container
* All dangling images
* All build cache
To run a docker image
1
docker run -d —name {chosen name} {image name:tag}
If an image has exited with a status code of other than 0, then it has not exited properly, perhaps there’s an error
1
docker logs {container name}