https://github.com/duffney/containers-from-scratch-cli
A simple Go CLI that builds Linux containers. Based on Liz Rice's https://github.com/lizrice/containers-from-scratch/tree/master
https://github.com/duffney/containers-from-scratch-cli
Last synced: about 1 month ago
JSON representation
A simple Go CLI that builds Linux containers. Based on Liz Rice's https://github.com/lizrice/containers-from-scratch/tree/master
- Host: GitHub
- URL: https://github.com/duffney/containers-from-scratch-cli
- Owner: duffney
- License: mit
- Created: 2023-10-30T14:27:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-08T15:53:23.000Z (over 1 year ago)
- Last Synced: 2025-04-10T01:04:04.546Z (about 1 month ago)
- Language: Go
- Homepage:
- Size: 55.7 MB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# containers-from-scratch-cli
**Who is this repo for?** If you've written a Dockerfile, built an image, run a container and now want to know what's going on under the hood, this repo is for you!
In this repo, is a Go CLI that mimic the Docker run and build commands. After building the cli and executing its commands, I encourage you to poke around the code base or watch the livestreams to indulge your curiosity about how containers work. :)
Step 1: Build the containerCLI
```bash
go build . -o containercli
```Step 2: Run a container with
A few notes:
- Container isolation is achieved by the use of a Linux Kernel feature called Namespaces.
- Resource constraint is achieved by the use of cgroups.## What's docker build doing?
Download Alpine for chroot:
```bash
mkdir alpine
cd alpine
curl -o alpine.tar.gz http://dl-cdn.alpinelinux.org/alpine/v3.10/releases/x86_64/alpine-minirootfs-3.10.0-x86_64.tar.gz
tar xvf alpine.tar.gz
rm alpine.tar.gz
touch ALPINE_CONTAINER_ROOT
```Download Ubuntu for chroot:
```bash
sudo apt install debootstrap
sudo debootstrap jammy ./ubuntu-rootfs http://archive.ubuntu.com/ubuntu/
```stress mem and cpu
```bash
./stress --vm 1 --vm-bytes 100M
```