Exercise: Build an Image and Run It

Test yourself and implement what you have learned so far in this exercise.

svg viewer

Create a file named compute.js with the following code that computes and displays the area of a disk using JavaScript:

compute.js

svg viewer

Create a Docker image that runs the code in compute.js file using the node:11-alpine image that contains Node.JS. The command that runs a JavaScript program using Node.JS is node <filename>.

The base image is already provided for you. Write the additional commands to complete the Dockerfile. You don’t have to worry about writing the commands to build and run the Dockerfile as they will be executed automatically when the RUN button is pressed.

/
Dockerfile
compute.js

You may find the source code for the compute.js file in the create-docker-images/exercises/jsimage/starter folder, and the source code for the solution in the create-docker-images/exercises/jsimage/solution folder.


Let’s go over the solution in the next lesson.

Images Are Created Locally
Exercise Solution
Mark as Completed
Report an Issue