Run ratings in Docker
This module shows how you create a Docker image and run it locally.
Download the for the microservice.
Observe the
Dockerfile
.$ cat Dockerfile
Create an environment variable to store your user id which will be used to tag the docker image for
ratings
service. For example, .Build a Docker image from the
Dockerfile
:...
Step 9/9 : CMD node /opt/microservices/ratings.js 9080
---> Using cache
---> 77c6a304476c
Successfully built 77c6a304476c
Run ratings in Docker. The following docker run command instructs Docker to expose port
9080
of the container to port9081
of your computer, allowing you to access theratings
microservice on port9081
.-
$ curl localhost:9081/ratings/7
{"id":7,"ratings":{"Reviewer1":5,"Reviewer2":4}}
Observe the running container. Run the command to list all the running containers and notice the container with the image .
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 cluster.