An intentionally-limited Rust implementation of the Docker runtime with no external dependencies.

Overview

lil-docker

An lightweight Rust implementation of Docker's run command.

lil docker is an accessible implementation of a very basic Docker runner (which allows you to execute arbitrary commands on any Docker image), with no external dependencies (other than tokio and other utils).

Motivation

I've been trying to get more serious about learning Rust lately, and what better way to learn than by debugging. So, when I discovered CodeCrafters (a platform that helps you get better at coding by guiding you through rebuilding popular tools, referral link w/ discount), and after completing their Redis build, I decided to try my hand at Docker.

Since the platform encourages you to come up with your own implementations, I've tried my best to make things as clean as possible (while hopefully keeping it simple enough for a beginner to understand). If you want to try your hand at it, I'd recommend going through the guide first, then comparing your solution to this one.

By sharing my implementation publicly, I hope to both attract others interested in learning Rust (who can use it as a learning resource) and already proficient with it (who can share which things they'd have done differently. PRs welcome!).

Structure

The codebase is structured as follows:

lil-docker/
├─ src/
│ ├─ main.rs: What gets called when you run the project
│ ├─ hub.rs: Logic for authenticating with the Docker Hub, and fetching images.
│ ├─ image.rs: Logic for running downloaded images and isolating them from the current system.
├─ Cargo.toml
├─ README.md

If you want to explore the codebase, I'd recommend starting with the main.rs file and going from there

Note You can press . while on GitHub to launch a web VSCode instance, which should help you navigate the project better.

Usage

Since running the program requires root (in order to properly isolate the processes), we're running our Docker implementation inside of a Docker container. To make things easier, you can declare the following alias

alias lil_docker='docker build -t lil_docker . && docker run --cap-add="SYS_ADMIN" lil_docker'

Then, run commands as you would with docker: lil_docker run alpine:latest echo hi

Develop

Make sure you have the latest version of rust installed (use rustup). Then, you can build the project by running cargo build, and run it with cargo run.

License

This project is open-sourced under the MIT license. See the License file for more information.

You might also like...
Darwinia networks' tracing runtime override collections

Darwinia Runtime Overrides USAGE: runtime-overrides [OPTIONS] --runtime CHAIN OPTIONS: -h, --help Print help information

A re-write of polkadot staking miner using subxt to avoid hard dependency to each runtime version

Staking Miner v2 WARNING this library is under active development DO NOT USE IN PRODUCTION. The library is a re-write of polkadot staking miner using

JS Runtime proof-of-concept for interactions with AvdanOS

Important: we are migrating to a new Discord server .gg/avdanos What is this ? This repo aims to be a JavaScript environment where AvdanOS extensions

Faterium Substrate Node, Runtime, and Pallets. Contains "faterium-polls-pallet" with logic of Faterium Polls.

Faterium Substrate Node Faterium - a place where fates are forged. This is the official implementation of Faterium Crowdfunding Polls in Rust as Subst

A modern runtime for javascript.

Just NOTICE: README LINKS AND SITE ARE WIP. LINKS MAY NOT WORK Just is a simple, and modern runtime for JavaScript that uses V8 and is built in Rust.

Fast way to test a Substrate Runtime via RPC (eg. PolkadotJS UI).

runstrate Fast way to test a Substrate Runtime via RPC (eg. PolkadotJS UI). Build & Run git clone https://github.com/arturgontijo/runstrate cd runstra

A fast zero-knowledge proof friendly Move language runtime environment.
A fast zero-knowledge proof friendly Move language runtime environment.

zkMove Lite zkMove Lite is a lightweight zero-knowledge proof friendly Move language virtual machine. Move bytecode is automatically "compiled" into c

Built on the Substrate-based runtime, this repository develops the Paralink Network, a cross-chain Oracle platform for secure and scalable data integration. Our goal is to create a robust infrastructure that ensures efficient and reliable data transmission across blockchain networks.
Marvin-Blockchain-Rust: A Rust-based blockchain implementation, part of the Marvin blockchain project.

Marvin Blockchain - Rust Implementation Welcome to the Rust implementation of the Marvin Blockchain. This project is part of a comparative study on bu

Owner
Miguel Piedrafita
20-year-old maker
Miguel Piedrafita
Temporary edit external crates that your project depends on

rhack You want to quickly put a sneaky macro kind of like dbg! into external crates to find out how some internal data structure works? If so rhack is

Ryo Nakao 119 Nov 3, 2022
Demo: Connect Phala's Fat Contract to external storage services, both centralized (Amazon s3) and decentralized .

This demo shows how to connect Phala's Fat Contract to external storage services, both centralized (Amazon s3) and decentralized (Arweave/Filecoin thr

Christopher Fok 2 Aug 30, 2022
A cargo subcommand for displaying when Rust dependencies are out of date

cargo-outdated Linux: A cargo subcommand for displaying when Rust dependencies are out of date About cargo-outdated is for displaying when dependencie

Kevin K. 911 Dec 30, 2022
miniserde minus the dependencies

Microserde Microserde is miniserde minus the dependencies. All credit goes to David Tolnay for the original library. From miniserde: Prototype of a da

Alexis Sellier 18 Feb 26, 2022
Audit Cargo.lock files for dependencies with security vulnerabilities

RustSec Crates ?? ??️ ?? The RustSec Advisory Database is a repository of security advisories filed against Rust crates published via crates.io. The a

RustSec 1.2k Dec 30, 2022
Generates a big overview of dependencies between microservices using pact-broker

Pact graph network Generates a schema of dependencies between microservices using pact-broker data. Table of contents Screenshots Tech Stack Features

ManoMano Tech 3 Dec 15, 2022
A runtime for Yarn Spinner scripts, written in Rust.

yarn_spool yarn_spool is a runtime for Yarn Spinner scripts, written in Rust. Note that this library does not provide tools for parsing Yarn scripts,

Joe Clay 3 Dec 21, 2022
A node and runtime configuration for polkadot node.

MANTA NODE This repo is a fresh FRAME-based Substrate node, forked from substrate-developer-hub/substrate-node-templte ?? It links to pallet-manta-dap

Manta Network 14 Apr 25, 2021
The Solana Program Library (SPL) is a collection of on-chain programs targeting the Sealevel parallel runtime.

Solana Program Library The Solana Program Library (SPL) is a collection of on-chain programs targeting the Sealevel parallel runtime. These programs a

null 6 Jun 12, 2022
A Secure Capability-Based Runtime for JavaScript Based on Deno

Secure Runtime secure-runtime, as the name implies, is a secure runtime for JavaScript, designed for the multi-tenant serverless environment. It is an

Gigamono 7 Oct 7, 2022