{"id":23057995,"url":"https://github.com/srodi/container-101","last_synced_at":"2026-05-20T05:42:41.814Z","repository":{"id":261807767,"uuid":"884524703","full_name":"SRodi/container-101","owner":"SRodi","description":"The project aims to demonstrate the basics of container creation and management on a Linux machine.","archived":false,"fork":false,"pushed_at":"2024-11-18T10:09:13.000Z","size":2758,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-18T11:29:57.363Z","etag":null,"topics":["cgroups","containers","linux","network-namespaces"],"latest_commit_sha":null,"homepage":"https://www.srodi.com/posts/what-is-a-container/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SRodi.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}},"created_at":"2024-11-06T22:59:13.000Z","updated_at":"2024-11-18T10:09:17.000Z","dependencies_parsed_at":"2024-11-08T15:38:07.517Z","dependency_job_id":null,"html_url":"https://github.com/SRodi/container-101","commit_stats":null,"previous_names":["srodi/container-101"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SRodi%2Fcontainer-101","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SRodi%2Fcontainer-101/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SRodi%2Fcontainer-101/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SRodi%2Fcontainer-101/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SRodi","download_url":"https://codeload.github.com/SRodi/container-101/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229897391,"owners_count":18141135,"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","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":["cgroups","containers","linux","network-namespaces"],"created_at":"2024-12-16T02:14:09.910Z","updated_at":"2026-05-20T05:42:41.783Z","avatar_url":"https://github.com/SRodi.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Create a container with a Bash script\n\nThis repo contains a script to create a basic Linux container using Bash. The steps include configuring Linux cgroups, creating network namespaces, and setting up a root filesystem. Executing the script will create the container and start an interactive shell inside it.\n\n## Functionalities\n\nHere is a breakdown of the `create.sh` script functionalities:\n\n1. Create `Filesystem`: Downloads and extracts the Alpine Linux miniroot filesystem into /mnt/mycontainer. Creates a /proc directory inside the container's filesystem.\n2. Set Up `cgroups`: Creates a cgroup named mycontainer for memory and CPU.\n3. Set Up `Network Namespace`:\n   * Creates a network namespace called mycontainer_ns.\n   * Creates a virtual Ethernet (veth) pair, veth0 and veth1.\n   * Assigns veth1 to the mycontainer_ns namespace.\n   * Configures IP addresses for veth0 and veth1.\n4. Run `unshare` within the network namespace to create a new mount namespace, a new PID namespace, and mounts the proc filesystem, then `chroots` into the container's filesystem and starts a shell.\n\n## Demo \n\nThis script essentially sets up a basic containerized environment with network isolation and a separate process namespace. The demo also shows the network communication from container to host and vice versa, this is done with the `veth` configuration in `create.sh`.\n\n![Demo](demo.gif)\n\n## Prerequisites\n\n1. Linux machine with kernel version \u003e= 5.8\n2. `libcgroup-dev` and `debootstrap`\n\nInstall the following\n\n```sh\nsudo apt update \u0026\u0026 sudo apt upgrade -y\nsudo apt install -y libcgroup-dev debootstrap\n```\n\n## Quickstart\n\nTo create the container\n```sh\nsudo ./create.sh\n```\n\nTo delete the container\n```sh\nsudo ./delete.sh\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrodi%2Fcontainer-101","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrodi%2Fcontainer-101","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrodi%2Fcontainer-101/lists"}