The container image can be started locally by running it within Docker. As we now have a container image, a container can be created:
- Run the following docker container run command:
docker container run --publish 8123:80 --detach --name [container name] [image name]
The preceding command will start the container image specified at the end of the command. In addition, different arguments are specified:
-
- Publish: The publish argument opens a port from the host to the container. As mentioned in the example, this will open port 8123 and will route traffic to port 80 within the container.
- Detach: The detach argument will run the container in the background and print out its specific ID.
- Name: The name for the container within Docker.
- To list all running containers, use the docker ps command within the Terminal.
- With the container running, open a browser and navigate to http://localhost:8123. If everything works fine, this should show a default ASP.NET Core web page:
Since building stuff locally and running it on your machine is not really the DevOps way of thinking, we will move to a different hosting platform in the upcoming sections.