{"id":31287935,"url":"https://github.com/kartikk-26/docker-container-lifecycle","last_synced_at":"2026-05-16T08:09:46.249Z","repository":{"id":314417560,"uuid":"1055433614","full_name":"Kartikk-26/Docker-Container-Lifecycle","owner":"Kartikk-26","description":"This repository contains a hands-on Docker 101 puzzle designed to teach beginners how Docker containers behave like both processes and isolated filesystems.","archived":false,"fork":false,"pushed_at":"2025-09-12T09:04:48.000Z","size":300,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-12T11:23:55.054Z","etag":null,"topics":["devops-tools","docker","docker-compose","docker-container"],"latest_commit_sha":null,"homepage":"https://labs.iximiuz.com/challenges/docker-101-container-stop-and-restart?s=08","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kartikk-26.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-12T09:02:42.000Z","updated_at":"2025-09-12T09:06:05.000Z","dependencies_parsed_at":"2025-09-12T11:24:00.937Z","dependency_job_id":"9c96ecc3-fecd-47f0-ade0-eff1909d6ecf","html_url":"https://github.com/Kartikk-26/Docker-Container-Lifecycle","commit_stats":null,"previous_names":["kartikk-26/docker-container-lifecycle"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Kartikk-26/Docker-Container-Lifecycle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kartikk-26%2FDocker-Container-Lifecycle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kartikk-26%2FDocker-Container-Lifecycle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kartikk-26%2FDocker-Container-Lifecycle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kartikk-26%2FDocker-Container-Lifecycle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kartikk-26","download_url":"https://codeload.github.com/Kartikk-26/Docker-Container-Lifecycle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kartikk-26%2FDocker-Container-Lifecycle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276740178,"owners_count":25696308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-24T02:00:09.776Z","response_time":97,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["devops-tools","docker","docker-compose","docker-container"],"created_at":"2025-09-24T11:35:56.051Z","updated_at":"2025-09-24T11:35:57.616Z","avatar_url":"https://github.com/Kartikk-26.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\n---\n\n# 🐳 Docker Container Lifecycle Puzzle Guide\n\n## 🔗 Go and Try This Puzzle\n\nTo experience this challenge hands-on, visit the official Docker 101 puzzle:\n\n👉 [Docker 101: Stop and Restart a Containerized Application](https://labs.iximiuz.com/challenges/docker-101-container-stop-and-restart?s=08)\n\nThis interactive lab allows you to practice stopping and restarting containers while exploring their filesystem.\n\n---\n\n## 🧩 What Is This Puzzle About?\n\nThis puzzle helps you understand **data persistence in Docker containers**.\n\n* **Containers = processes**: You can start, stop, and restart them like regular programs.\n* **Containers = mini-filesystems**: Each has its own isolated root filesystem, created from the Docker image plus a writable layer.\n\n👉 **Key idea**: Stopping a container keeps data; removing a container deletes it (unless you use volumes).\n\n---\n\n## 🛠️ What You’ll Learn\n\n* How to stop and restart containers.\n* How to inspect and modify a container’s filesystem.\n* The difference between stopping and removing containers.\n* How data persists across stops and starts but is lost when containers are removed.\n\n---\n\n## 📝 Step-by-Step Solution\n\n### Step A: Add Some Records\n\n1. Open the web interface of the finance tracker.\n2. Add records like `Income 1000` or `Expense 200`.\n3. Verify inside the container:\n\n   ```bash\n   docker exec -it CONTAINER_NAME_OR_ID cat /var/lib/app/ledger.txt\n   ```\n\n   You should see your records.\n\n### Step B: Stop the Container\n\nRun:\n\n```bash\ndocker stop CONTAINER_NAME_OR_ID\n```\n\n* Sends a `SIGTERM` for graceful shutdown.\n* Docker forces `SIGKILL` if it takes too long.\n* The web app becomes unresponsive.\n\n### Step C: Restart the Container\n\nRun:\n\n```bash\ndocker start CONTAINER_NAME_OR_ID\n```\n\n* Container resumes with the same writable layer.\n* Reload the web interface → **records are still there** 🎉\n\n### Step D: Remove the Container\n\nFirst, stop it (if still running):\n\n```bash\ndocker stop CONTAINER_NAME_OR_ID\n```\n\nThen remove it:\n\n```bash\ndocker rm CONTAINER_NAME_OR_ID\n```\n\n* Container and writable layer are deleted.\n* Data inside `/var/lib/app/ledger.txt` **is gone**.\n\n### Step E: Start a New Container from the Same Image\n\nRun:\n\n```bash\ndocker run -d --name my-finance -p 8080:8080 registry.iximiuz.com/my-finance\n```\n\n* Launches a fresh container.\n* Open the web interface → **no old records exist**.\n\n---\n\n## ✅ Final Outcome\n\n* **Stop → Start**: Data is preserved ✅\n* **Remove → Run new**: Data is lost ❌\n\nThis demonstrates the difference between:\n\n* Container lifecycle (stop/start keeps data)\n* Container removal (removes data)\n\n---\n\n## 🧠 Beginner-Friendly Summary\n\n* A container = running program + mini computer with its own filesystem.\n* Stop a container → nothing is lost.\n* Remove a container → everything inside is deleted.\n* New container from same image = fresh start.\n\n**Goal**: Show that stopping keeps data ✅, removing destroys data ❌\n\n**One-liner**: Stopping a container is like putting your laptop to sleep; removing it is like throwing it away and buying a new one.\n\n---\n\n## 🖼️ Visuals\n\n### Container Filesystem Diagram\n\n![Container Filesystem Diagram](./Assests/container-rootfs-image.png)\n\n*Illustration of Docker's layered filesystem, showing the read-only image layers and the writable container layer.*\n\n### Expected Output Screenshot\n\n![Expected Output Screenshot](./Assests/WhatsApp%20Image%202025-09-10%20at%2008.42.54_b7183fd7.jpg)\n\n*Example of the terminal output after inspecting the container's filesystem.*\n\n---\n\nFeel free to explore the challenge and experiment with the steps to deepen your understanding of Docker container lifecycles and data persistence.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkartikk-26%2Fdocker-container-lifecycle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkartikk-26%2Fdocker-container-lifecycle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkartikk-26%2Fdocker-container-lifecycle/lists"}