{"id":25867495,"url":"https://github.com/jdmary/docker-sample","last_synced_at":"2025-10-12T22:26:52.194Z","repository":{"id":276656211,"uuid":"929789294","full_name":"JdMary/docker-sample","owner":"JdMary","description":"A comprehensive Docker sample project featuring practical labs and in-depth guides to master containerization efficiently.","archived":false,"fork":false,"pushed_at":"2025-02-26T20:34:35.000Z","size":4559,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-18T19:55:03.974Z","etag":null,"topics":["docker","dockerfile","dockerfile-examples"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","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/JdMary.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}},"created_at":"2025-02-09T12:10:00.000Z","updated_at":"2025-02-27T13:19:11.000Z","dependencies_parsed_at":"2025-02-25T23:24:40.164Z","dependency_job_id":"d62ca3dc-918f-4506-b734-effae702c0b8","html_url":"https://github.com/JdMary/docker-sample","commit_stats":null,"previous_names":["jdmary/docker-sample"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JdMary/docker-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JdMary%2Fdocker-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JdMary%2Fdocker-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JdMary%2Fdocker-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JdMary%2Fdocker-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JdMary","download_url":"https://codeload.github.com/JdMary/docker-sample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JdMary%2Fdocker-sample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013265,"owners_count":26085250,"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-10-12T02:00:06.719Z","response_time":53,"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":["docker","dockerfile","dockerfile-examples"],"created_at":"2025-03-02T03:35:34.763Z","updated_at":"2025-10-12T22:26:52.171Z","avatar_url":"https://github.com/JdMary.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-sample\n## Diffrent methods of image creation:\n1. Create an image from Scratch \n2. Create an image from a Dockerfile\n3. Create an image from a Container\n\n### Creating a Docker Image FROM Scratch  \n\nBuilding Docker images **FROM scratch** means starting from an **empty base**, without any preinstalled OS, ensuring **lightweight, secure, and fully controlled** containerization.\n\n#### Why use FROM scratch?  \n- **Minimal size**\n- **Enhanced security**\n- **Full control over dependencies**\n\n####  Example: Ultra-Lightweight Docker Image  \n\n```dockerfile\nFROM scratch  \nCOPY hello /  \nCMD [\"/hello\"]\n```\n\n### Dockerfile: The Preferred Method for Building a Docker Image  \n\nA **Dockerfile** is a script that defines step by step how to build a Docker image in an **automated, efficient, and reproducible** way. It acts as a **recipe**, ensuring consistency across deployments. \n\n#### Building an Image: `docker build`  \nThe essential command to create a Docker image:\n```\ndocker build -t image_name path\n```\n1. Define the base image\n```\nFROM ubuntu:20.04\n```\n2. Set up the environment\n```\nLABEL maintainer=\"Jrad Mariem\"\nENV APP_ENV=production\nWORKDIR /app\n```\n3. Define the startup behaviour\n  * The CMD command is the default command that will be executed but if an argument is entered when running the container it would ignore the CMD Statement \n  * The Entypoint is a base command which prioritary comparing it with CMD .\n  \n\u003e [!NOTE] \n\u003e **`ENTRYPOINT` vs. `--entrypoint` in Docker**\n\u003e - `ENTRYPOINT` (Dockerfile) sets a fixed command that runs by default.\n\u003e   ```dockerfile\n\u003e   ENTRYPOINT [\"ping\", \"-c\", \"4\"]\n\u003e   ```\n\u003e   Running `docker run my-image google.com` executes: `ping -c 4 google.com`.\n\u003e - `--entrypoint` (CLI) temporarily overrides `ENTRYPOINT`.\n\u003e   ```sh\n\u003e   docker run --entrypoint ls my-image\n\u003e   ```\n\u003e   Runs `ls` instead of `ping`. \n\u003e - **Use `ENTRYPOINT`** for default behavior, **`--entrypoint`** for runtime overrides. \n\n\n```\nCMD [\"echo\", \"Hello, World!\"]\nENTRYPOINT [\"echo\"]\n```\n4. Run commands during build which creates a temporary container and executes the command and from it an image will be created\n```\nRUN apt-get update \u0026\u0026 apt-get install -y python3\n```\n\n### Create a Docker Image from a Container  \n\nUse `docker commit` to save a container’s current state as a new image. \n\n#### Syntax  \n```\ndocker commit [container_id] [image_name:tag]\n```\n# Docker Swarm Setup\n\nThis README contains essential commands for setting up and managing a Docker Swarm cluster.\n\n## 1. **Initialize Swarm**\n\nTo initialize a new Swarm on a manager node, run the following command:\n\n```bash\ndocker swarm init\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdmary%2Fdocker-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdmary%2Fdocker-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdmary%2Fdocker-sample/lists"}