Search⌘ K
AI Features

Exercise: Enable an Image to Be Parameterized

Explore how to parameterize a Docker image using environment variables by creating and running containers with different values. This lesson helps you understand setting environment variables in Dockerfiles and container commands to control application execution.

We'll cover the following...
svg viewer

In the create-docker-images/exercises/jsparam/starter folder you’ll find a compute.js file with the following code:

Javascript (babel-node)
var radius = process.env.diameter / 2;
var area = Math.pow(radius, 2) * Math.PI;
console.log(
`Area of a ${radius} cm radius disk:
${area} cm²`
);

svg viewer

It’s a modified version of the code from the ...