Ravindra BagaleCourses & study guides

Chapter 6: Docker Images and Containers

6.10 Lab — Dockerfile for badge API hello

Lab

Containerise the hello API from earlier Git chapters.

  1. Ensure the app has a health or root route you can curl.
  2. Write a Dockerfile (FROM / COPY / RUN / CMD / EXPOSE).
  3. Add .dockerignore excluding .env, .git, dependency caches.
  4. docker build -t badge-api-hello:0.1 .
  5. docker run -d --name badge-api -p 8080:8080 badge-api-hello:0.1
  6. curl the published host port; save the status code in your notes.
  7. docker logs badge-api and docker exec a simple command (ls / pwd).
  8. docker stop and docker rm the container. Keep the image for the next chapter if you like.

Practice task

List four Dockerfile instructions you used and one mistake each can cause if miswritten (wrong FROM, missing COPY, RUN without needed files, CMD vs shell form confusion).

Thodkyaat sangaycha tar

  • Containers box the app; VMs (EC2) are learned in depth in the AWS course — do not mix the stories.
  • Image = template; container = running instance; Dockerfile builds layered images.
  • Daily commands: build, run, ps, logs, exec, stop/rm.
  • -p host:container publishes published ports; EXPOSE alone does not open the host door.
  • Publish only needed ports; keep secrets out of image layers with .dockerignore.

Samajla ka? Nasel tar lab (6.10) sodun `curl` green yeiparyant build-run kara – `-p` aani app bind `0.0.0.0` donhi check kara. Aata pudhe jaauya Docker volumes, networks aani Compose kade.