Shallow Container is a light-weight container tool written in Rust.

Overview

Shallow Container

Shallow Container is a light-weight container tool written in Rust. It is totally for proof-of-concept and may not suit for production environment.

Shallow Container 是一款Rust编写的轻量级容器工具,用于探索在Rust中实现管理Linux命名空间等功能的可能性。请注意,本程序仅作为学习用途,其设计可能不适合生产用途,请勿在生产环境下使用。

在开发本项目时并没有考虑到诸多方面,致使本项目更像是一个玩具,如果需要细致了解Docker的原理,推荐研究Linux Namespace、cgroups、aufs等知识。

概念

Rust是一门非常棒的编程语言,在这入门后不到一年的时间,我逐渐感受到了Rust的魅力,并尝试以Rust为切入点去理解后端框架、操作系统等应用。Shallow Container(简称SC)是100% Rust编写的轻型容器工具,目前支持下面的功能:

  • 从Docker Hub下载镜像
  • 启动镜像(可选和主机共享Net命名空间)

SC在设计上一定程度参考了mocker,我和mocker的作者一样花了两天时间写了这样一个程序。程序功能完全比不上Docker的n分之一,在实际执行的过程中也可能有不少问题,不过这已经达到了探索基础知识的目的,后续更深入的容器原理就交给大家和我独自去研究了。

SC的所有文件均保存在/var/lib/shallow中,如果需要释放空间,直接删除即可。

pull

假设程序编译位置为./target/debug/shallow-container,如果想pull一个镜像,请执行下面的命令:

$ sudo ./target/debug/shallow-container pull library/hello-world:latest

Image需要是完整的scope/image:tag格式,如果为官方镜像,scope请设置为library。你大概会看到这样的输出:

Pull Hello World

run

类似的,如果想启动一个容器,请执行下面的命令,如果没找到镜像会先尝试pull:

$ sudo ./target/debug/shallow-container run library/hello-world:latest

默认情况下,SC会为容器使用独立的PID、Net等命名空间。由于SC设计上未考虑到网络相关的功能,所以如果你想运行Nginx容器,可以加上--Sn来和主机共享网络命名空间。

$ sudo ./target/debug/shallow-container run --Sn nginxinc/nginx-unprivileged:latest

可以预期的输出如下:

Run Nginx

同时你可以访问http://127.0.0.1:8080,你应该能够看到Nginx经典的默认网页。

License

Shallow Container is available under terms of Apache-2.0.

You might also like...
Runc - CLI tool for spawning and running containers according to the OCI specification

runc Introduction runc is a CLI tool for spawning and running containers on Linux according to the OCI specification. Releases You can find official r

A simple containerized application manage system like Kubernetes, but written in Rust
A simple containerized application manage system like Kubernetes, but written in Rust

rMiniK8s A simple dockerized application management system like Kubernetes, written in Rust, plus a simple FaaS implementation. Course Project for SJT

Automated builded images for rust-lang with rustup, "the ultimate way to install RUST"

rustup Automated builded images on store and hub for rust-lang with musl added, using rustup "the ultimate way to install RUST". tag changed: all3 -

docker-rust — the official Rust Docker image

About this Repo This is the Git repo of the Docker official image for rust. See the Docker Hub page for the full readme on how to use this Docker imag

Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.

rust-musl-builder: Docker container for easily building static Rust binaries Source on GitHub Changelog UPDATED: Major updates in this release which m

Very small rust docker image

mini-docker-rust Very small rust docker image. This is an example project on how to build very small docker images for a rust project. The resulting i

Docker images for compiling static Rust binaries using musl-cross

rust-musl-cross Docker images for compiling static Rust binaries using musl-cross-make, inspired by rust-musl-builder Prebuilt images Currently we hav

A wasm template for Rust to publish to gh-pages without npm-deploy
A wasm template for Rust to publish to gh-pages without npm-deploy

Wasm template for Rust hosting without npm-deploy on github pages using Travis script It automatically hosts you wasm projects on gh-pages using a tra

App Engine Rust boilerplate

Rust App Engine This projects is a minimal boilerplate ro run Rust web application inside Google App Engine. To deploy it use Google Cloud Shell: ```s

Owner
Rui Li
A beginner in programming, looking for internship opportunities. Email: lr_cn[at]outlook.com
Rui Li
insject is a tool for poking at containers. It enables you to run an arbitrary command in a container or any mix of Linux namespaces.

Insject insject is a tool for poking at containers. It enables you to run an arbitrary command in a container or any mix of Linux namespaces. It suppo

NCC Group Plc 44 Nov 9, 2022
A tiny minimal container runtime written in Rust.

vas-quod A tiny minimal container runtime written in Rust. The idea is to support a minimal isolated containers without using existing runtimes, vas-q

flouthoc 438 Dec 26, 2022
Easy to use, extendable, OCI-compliant container runtime written in pure Rust

PURA - Lightweight & OCI-compliant container runtime Pura is an experimental Linux container runtime written in pure and dependency-minimal Rust. The

Branimir Malesevic 73 Jan 9, 2023
Container monitor in Rust

Conmon-rs A pod level OCI container runtime monitor. The goal of this project is to provide a container monitor in Rust. The scope of conmon-rs encomp

Containers 84 Dec 21, 2022
A secure container runtime with OCI interface

Quark Container Welcome to Quark Container. This repository is the home of Quark Containers code. What's Quark Container Quark Container is high perfo

null 175 Dec 29, 2022
Hot-plug devices into a Docker container as they are plugged.

container-hotplug Hot-plug (and unplug) devices into a Docker container as they are (un)plugged. Description Docker provides the --device flag to give

lowRISC 2 Oct 17, 2022
dedock is a container runtime, with a particular focus on enabling embedded software development across all platforms

dedock is a container runtime, with a particular focus on enabling embedded software development across all platforms. It supports native "containers" on both Linux and macOS.

Daniel Mangum 12 May 27, 2023
An infrastructure-as-code and deployment tool for Roblox.

Rocat ?? An infrastructure-as-code and deployment tool for Roblox. ⚠ Please note that this is an early release and the API is unstable. Releases follo

Blake Mealey 45 Dec 29, 2022
An infrastructure-as-code and deployment tool for Roblox.

Mantle ?? An infrastructure-as-code and deployment tool for Roblox. ⚠ Please note that this is an early release and the API is unstable. Releases foll

Blake Mealey 44 Dec 22, 2022
Tool to monitor the statistics and the energy consumption of docker containers

Docker Activity Docker activity is a tool to monitor the statistics of your containers and output their energy consumption. Warning It's still in earl

Jérémie Drouet 39 Dec 6, 2022