{"id":13667800,"url":"https://github.com/KernelErr/shallow-container","last_synced_at":"2025-04-26T18:30:34.974Z","repository":{"id":129726992,"uuid":"408061057","full_name":"KernelErr/shallow-container","owner":"KernelErr","description":"A light-weight container tool written in Rust.","archived":false,"fork":false,"pushed_at":"2021-09-22T11:23:08.000Z","size":399,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-26T12:56:11.584Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","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/KernelErr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-09-19T07:25:42.000Z","updated_at":"2023-08-28T04:00:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"f2dcb684-228d-47ac-bf15-77a579cf43e1","html_url":"https://github.com/KernelErr/shallow-container","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KernelErr%2Fshallow-container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KernelErr%2Fshallow-container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KernelErr%2Fshallow-container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KernelErr%2Fshallow-container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KernelErr","download_url":"https://codeload.github.com/KernelErr/shallow-container/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251035095,"owners_count":21526303,"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":[],"created_at":"2024-08-02T07:00:50.500Z","updated_at":"2025-04-26T18:30:34.426Z","avatar_url":"https://github.com/KernelErr.png","language":"Rust","readme":" \n\n![Shallow Container](./docs/logo.png)\n\nShallow Container is a light-weight container tool written in Rust. It is totally for proof-of-concept and may not suit for production environment.\n\nShallow Container 是一款Rust编写的轻量级容器工具，用于探索在Rust中实现管理Linux命名空间等功能的可能性。请注意，本程序仅作为学习用途，其设计可能不适合生产用途，请勿在生产环境下使用。\n\n在开发本项目时并没有考虑到诸多方面，致使本项目更像是一个玩具，如果需要细致了解Docker的原理，推荐研究Linux Namespace、cgroups、aufs等知识。\n\n## 概念\n\nRust是一门非常棒的编程语言，在这入门后不到一年的时间，我逐渐感受到了Rust的魅力，并尝试以Rust为切入点去理解后端框架、操作系统等应用。Shallow Container（简称SC）是100% Rust编写的轻型容器工具，目前支持下面的功能：\n\n- 从Docker Hub下载镜像\n- 启动镜像（可选和主机共享Net命名空间）\n\nSC在设计上一定程度参考了[mocker](https://github.com/tonybaloney/mocker)，我和mocker的作者一样花了两天时间写了这样一个程序。程序功能完全比不上Docker的n分之一，在实际执行的过程中也可能有不少问题，不过这已经达到了探索基础知识的目的，后续更深入的容器原理就交给大家和我独自去研究了。\n\nSC的所有文件均保存在`/var/lib/shallow`中，如果需要释放空间，直接删除即可。\n\n## pull\n\n假设程序编译位置为`./target/debug/shallow-container`，如果想pull一个镜像，请执行下面的命令：\n\n```bash\n$ sudo ./target/debug/shallow-container pull library/hello-world:latest\n```\n\nImage需要是完整的scope/image:tag格式，如果为官方镜像，scope请设置为`library`。你大概会看到这样的输出：\n\n![Pull Hello World](./docs/screenshots/pull_hello_world.png)\n\n## run\n\n类似的，如果想启动一个容器，请执行下面的命令，如果没找到镜像会先尝试pull：\n\n```bash\n$ sudo ./target/debug/shallow-container run library/hello-world:latest\n```\n\n默认情况下，SC会为容器使用独立的PID、Net等命名空间。由于SC设计上未考虑到网络相关的功能，所以如果你想运行Nginx容器，可以加上`--Sn`来和主机共享网络命名空间。\n\n```bash\n$ sudo ./target/debug/shallow-container run --Sn nginxinc/nginx-unprivileged:latest\n```\n\n可以预期的输出如下：\n\n![Run Nginx](./docs/screenshots/run_nginx.png)\n\n同时你可以访问`http://127.0.0.1:8080`，你应该能够看到Nginx经典的默认网页。\n\n## License\n\nShallow Container is available under terms of Apache-2.0.\n","funding_links":[],"categories":["库"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKernelErr%2Fshallow-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKernelErr%2Fshallow-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKernelErr%2Fshallow-container/lists"}