Skip to content

Latest commit

 

History

History
79 lines (61 loc) · 2.22 KB

File metadata and controls

79 lines (61 loc) · 2.22 KB

Day 1: Docker Fundamentals - Images & Containers

Concepts:

  • Images: Read-only templates used to create containers. They contain the application code, libraries, dependencies, and configurations.
  • Containers: Runnable instances of an image. They are isolated, lightweight environments where your application runs.
  • Docker Daemon: The background service that manages Docker objects.
  • Docker Client: The command-line tool (or other clients) that interacts with the Docker Daemon.
  • Docker Hub: A public registry for Docker images.

Examples:

  1. Install Docker: Follow the official Docker documentation for your operating system (Docker Desktop for Windows/macOS, or Docker Engine for Linux).

  2. Verify Installation:

docker --version
docker run hello-world

(The hello-world command pulls a tiny image and runs a container from it, printing a message.) 3. Pull an image:

docker pull ubuntu:latest
  1. Run a container from an image (non-interactive):
docker run ubuntu:latest echo "Hello from Ubuntu container! "
  1. Run an interactive container:
docker run -it --name my_ubuntu_shell ubuntu:latest /bin/bash

(This runs an Ubuntu container in interactive (-i) and pseudo-TTY (-t) mode, names it my_ubuntu_shell, and opens a bash shell inside it. Type exit to leave the container.)

  1. List running containers:
docker ps
  1. List all containers (running and stopped):
docker ps -a
  1. Stop a running container:
docker stop my_ubuntu_shell
  1. Restart a stopped container:
docker start my_ubuntu_shell
docker attach my_ubuntu_shell # Re-attach to the bash session
  1. Remove a container:
docker rm my_ubuntu_shell
  1. List images:
docker images
  1. Remove an image:
docker rmi ubuntu:latest

Challenge 1: First Container Interaction

  • Run a debian:latest container in interactive mode and try to install a package like curl inside it. What happens and why? (Hint: Think about what's included in a minimal Debian image.)
  • After exiting, try to start and re-attach to the same container.
  • Clean up by removing the container.