Run ratings in Docker
This module shows how you create a image and run it locally.
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 command instructs Docker to expose port of the container to port
9081
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 docker ps command to list all the running containers and notice the container with the image
<your user name>/ratings
.
You have learned how to package a single service into a container. The next step is to learn how to .