Publishing a web API to Docker
Docker is a tool used to create, deploy, and run applications by using containers. They work like VMs, but are more lightweight and use the host machine to provide better performance.
Note
To understand more about Docker, read the article What is Docker? found at https://www.docker.com/what-docker. Docker can be installed on your machine by following the appropriate steps for your machine, found at https://www.docker.com/products/docker. To use Docker, your machine should support hardware virtualization.
Once Docker is installed on the machine, go through the following steps to build a PacktContactsAPI
Docker image and run it on a Docker container:
- Right-click on the project name and go to
Add
|Docker Support
to create the Docker file. - In the
PacktContacts
project, createDockerfile
and copy the following code:
FROM microsoft/aspnetcore: 2.0 ENTRYPOINT ["dotnet", "PacktContacts.dll"] ARG source=. WORKDIR /app EXPOSE 80...