Skip to Content
Certified Kubernetes Application Developer (CKAD) Study Guide, 2nd Edition
book

Certified Kubernetes Application Developer (CKAD) Study Guide, 2nd Edition

by Benjamin Muschko
May 2024
Intermediate to advanced
366 pages
7h 58m
English
O'Reilly Media, Inc.
Content preview from Certified Kubernetes Application Developer (CKAD) Study Guide, 2nd Edition

Appendix A. Answers to Review Questions

Chapter 4, Containers

  1. The given Dockerfile builds a nodejs-based application. All files necessary to run the application are available in the same directory. Upon further inspection, you will find that the Dockerfile exposes port 3000.

    Build the container image with the following command:

    $ docker build -t nodejs-hello-world:1.0.0 .
    

    You will be able to find the container image by listing it:

    $ docker images
    REPOSITORY           TAG     IMAGE ID       CREATED          SIZE
    nodejs-hello-world   1.0.0   0cc723ca8b06   15 seconds ago   180MB
    

    Run the container in detached mode with the following command. Make sure to map port 80 to the exposed container port 3000:

    $ docker run -d -p 80:3000 nodejs-hello-world:1.0.0
    9e0f1abcef415e902422117de7644544cdd08ae158a1cd0b2a2d182fcf056cab
    

    You can discover details about the container by listing them:

    $ docker container ls
    CONTAINER ID   IMAGE                      COMMAND                  ...
    9e0f1abcef41   nodejs-hello-world:1.0.0   "docker-entrypoint.s…"   ...
    

    You can now access the application on port 80 with either curl or wget:

    $ curl localhost
    Hello World
    $ wget localhost
    
    --2023-05-09 08:38:30--  http://localhost/
    Resolving localhost (localhost)... ::1, 127.0.0.1
    Connecting to localhost (localhost)|::1|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    ...
    2023-05-09 08:38:30 (2.29 MB/s) - ‘index.html’ saved [12/12]
    

    You can retrieve logs written by the application with the following command:

    $ docker logs 9e0f1abcef41
    Magic happens on port 3000
    
  2. Change ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Certified Kubernetes Application Developer (CKAD), 4th Edition

Certified Kubernetes Application Developer (CKAD), 4th Edition

Sander van Vugt
Kubernetes and Cloud Native Associate (KCNA) Study Guide

Kubernetes and Cloud Native Associate (KCNA) Study Guide

Jorge Valenzuela Jiménez, Adrián González Sánchez

Publisher Resources

ISBN: 9781098152857Errata Page