.NET Tutorial - Your First Microservice

Run Docker image

You can run your app in a container using the following command:

Terminal
docker run -it --rm -p 3000:8080 --name mymicroservicecontainer mymicroservice

You can browse to the following URL to access your application running in a container: http://localhost:3000/weatherforecast

The API endpoint returns JSON data containing weather forecast information

Optionally, you can view your container running in a separate command prompt using the following command:

Optionally, you can view your container running in a separate terminal window using the following command:

Terminal
docker ps

A list of running docker images with information about each of them.

Press CTRL+C on your command prompt to end the docker run command that is running the service in a container.

Press CTRL+C on your terminal to end the docker run command that is running the service in a container.

Congratulations! You've successfully created a small, independent service that can be deployed and scaled using Docker containers.

These are the fundamental building blocks of microservices.

Got an error?

If you receive a message similar to ERROR: error during connect: this error may indicate that the docker daemon is not running, it may indicate that you need to launch the Docker application. Check that the Docker client is running by running docker run hello-world. This should pull and run the image. For more help, see the Docker documentation for instructions on how to diagnose and fix this issue.

Continue