Building the container

We use the same docker build command to create the container:

docker build .

You should see output that looks something like the following:

Sending build context to Docker daemon  197.6kB
Step 1/11 : FROM alpine
---> 76da55c8019d
Step 2/11 : RUN apk update
---> Using cache
---> b44cd5d0ecaa

As you saw with the Python-based example, every step in the Dockerfile is reflected with output showing you what happened as Docker was building the container image based on your instructions (the Dockerfile):

Step 9/11 : COPY . .
---> 6851a9088ce3
Removing intermediate container 9fa9b8b9d463
Step 10/11 : ENV DEBUG kfd-nodejs:*
---> Running in 663a2cd5f31f
---> 30c3b45c4023
Removing intermediate container 663a2cd5f31f
Step 11/11 : CMD npm start
---> Running in 52cf9638d065
---> 35d03a9d90e6
Removing intermediate container 52cf9638d065
Successfully built 35d03a9d90e6

As with the Python example, this builds a container with only an ID. This example also leverages Quay for hosting the images publicly, so we will take the image appropriately so we can upload it to Quay:

docker tag 35d03a9d90e6 quay.io/kubernetes-for-developers/nodejs

As with the Python example, the tag contains three relevant parts - quay.io is the container registry. The second (kubernetes-for-developers) is the namespace for your containers, and the third (nodejs) is the name of the container. The same commands as the Python example are used to upload the container, referencing nodejs instead of flask:

docker login quay.io
docker push quay.io/kubernetes-for-developers/nodejs
The push refers to a repository [quay.io/kubernetes-for-developers/nodejs]
0b6165258982: Pushed
8f16769fa1d0: Pushed
3b43ed4da811: Pushed
9e4ead6d58f7: Pushed
d56b3cb786f1: Pushedfad7fd538fb6: Pushing [==================> ] 11.51MB/31.77MB
5fbd4bb748e7: Pushing [==================================> ] 2.411MB/3.532MB
0d2acef20dc1: Pushing [==================================================>] 1.107MB
5bef08742407: Pushing [================> ] 1.287MB/3.966MB

And when it is complete, you should see something akin to the following:

The push refers to a repository [quay.io/kubernetes-for-developers/nodejs]
0b6165258982: Pushed
8f16769fa1d0: Pushed
3b43ed4da811: Pushed
9e4ead6d58f7: Pushed
d56b3cb786f1: Pushed
fad7fd538fb6: Pushed
5fbd4bb748e7: Pushed
0d2acef20dc1: Pushed
5bef08742407: Pushed
latest: digest: sha256:0e50e86d27a4b29b5b10853d631d8fc91bed9a37b44b111111dcd4fd9f4bc723 size: 6791

Like the Python example, you may want to build and tag in the same command. For the Node.js example, that command would be:

docker build -t quay.io/kubernetes-for-developers/nodejs:0.2.0 .

This, if run immediately after you built the image, should display output that looks like the following:

Sending build context to Docker daemon  197.6kB
Step 1/11 : FROM alpine
---> 76da55c8019d
Step 2/11 : RUN apk update
---> Using cache
---> b44cd5d0ecaa
Step 3/11 : RUN apk upgrade
---> Using cache
---> 0b1caea1a24d
Step 4/11 : RUN apk add nodejs nodejs-npm
---> Using cache
---> 193d3570516a
Step 5/11 : WORKDIR /src
---> Using cache
---> 3a5d78afa1be
Step 6/11 : COPY package.json .
---> Using cache
---> 29724b2bd1b9
Step 7/11 : COPY package-lock.json .
---> Using cache
---> ddbcb9af6ffc
Step 8/11 : RUN npm install --production
---> Using cache
---> 1556a20af49a
Step 9/11 : COPY . .
---> Using cache
---> 6851a9088ce3
Step 10/11 : ENV DEBUG kfd-nodejs:*
---> Using cache
---> 30c3b45c4023
Step 11/11 : CMD npm start
---> Using cache
---> 35d03a9d90e6
Successfully built 35d03a9d90e6
Successfully tagged quay.io/kubernetes-for-developers/nodejs:latest

Again, it will be significantly faster as it was using Docker's cache of the image layers that were previously built.

If you run the docker images command, you should now see it listed:

REPOSITORY                                TAG       IMAGE ID      CREATED          SIZE
quay.io/kubernetes-for-developers/nodejs 0.2.0 46403c409d1f 4 minutes ago 81.9MB
If you are pushing your own images to quay.io as a container repository, you may need to log in to the website and make the images public in addition to these commands. By default, quay.io will keep images private, even the public ones, until you approve their exposure on their website.