Run ratings in Docker
This module shows how you create a Docker6 image and run it locally.
Download the
Dockerfile
7 for theratings
microservice.Observe the
Dockerfile
.Note that it copies the files into the container’s filesystem and then runs the
npm install
command you ran in the previous module. TheCMD
command instructs Docker to run theratings
service on port9080
.Create an environment variable to store your user id which will be used to tag the docker image for
ratings
service. For example,user
.Build a Docker image from the
Dockerfile
:Run ratings in Docker. The following docker run8 command instructs Docker to expose port
9080
of the container to port9081
of your computer, allowing you to access theratings
microservice on port9081
.Access http://localhost:9081/ratings/79 in your browser or use the following
curl
command:Observe the running container. Run the docker ps10 command to list all the running containers and notice the container with the image
<your user name>/ratings
.Stop the running container:
You have learned how to package a single service into a container. The next step is to learn how to deploy the whole application to a Kubernetes cluster11.