Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gotha/bicr
Bat Itso's Contaier Runtime
https://github.com/gotha/bicr
containers hobby-project linux
Last synced: about 2 months ago
JSON representation
Bat Itso's Contaier Runtime
- Host: GitHub
- URL: https://github.com/gotha/bicr
- Owner: gotha
- License: other
- Created: 2023-12-19T19:29:29.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-13T07:31:52.000Z (about 1 year ago)
- Last Synced: 2024-06-19T16:38:43.314Z (7 months ago)
- Topics: containers, hobby-project, linux
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# BI Container Runtime
## Build
```sh
make build
```## Run
!Note: Make sure you have created rootfs first and ROOTFS env variable is set (see below).
Without any parameters bicr-run starts a shell inside the container
```sh
./build/bicr-run
```you can run specific commands from the container:
```sh
./build/bicr-run /bin/env
```You can test with the example web server
```sh
cp ./build/bicr-httpd-example ./build/rootfs/opt
PORT=9999 ./build/bicr-run /opt/bicr-httpd-example
```### Creating root filesystem
```sh
export ROOTFS="$(pwd)/build/rootfs"
mkdir -pv $ROOTFS
```Depending on the flavour of Linux you like, you can use either minimalistic BusyBox environment or Debian, Arch, Fedora.
Here are some examples:
#### [busybox](https://busybox.net/)
##### From source code
This is the default one.
You need to have installed `gcc`, `g++`, `make` and what Debian calls `build-essentials`
```sh
export MAKEFLAGS=-j`nproc` && make rootfs
```when the config menu appears go to `Settings -> Build Options` and select `Build static binary`, then exit and save configuration.
##### Get busybox out of docker image
```sh
docker create busybox
CID=$(docker container ls -a --format json | grep busybox | jq -r '.ID')
docker export $CID | tar -xf - -C $ROOTFS
```#### build [alpine](https://www.alpinelinux.org/)
```sh
pushd /tmp
wget http://dl-cdn.alpinelinux.org/alpine/v3.19/main/x86_64/apk-tools-static-2.14.0-r5.apk
mkdir -pv /tmp/apk-tools
tar -xf apk-tools-static-2.14.0-r5.apk -C /tmp/apk-tools
popdsudo /tmp/apk-tools/sbin/apk.static \
-X http://dl-cdn.alpinelinux.org/alpine/v3.19/main -U \
--arch x86_64 \
--allow-untrusted --root $ROOTFS \
--initdb add alpine-base gcompat
```#### [debootstrap](https://wiki.debian.org/Debootstrap)
```sh
debootstrap bookworm $ROOTFS http://deb.debian.org/debian/
```#### [pacstrap](https://wiki.archlinux.org/title/Pacstrap)
```sh
pacstrap -K $ROOTFS base vim
```#### DNF on Fedora, RHEL, etc
```sh
sudo dnf -y --releasever=39 --installroot=$ROOTFS \
--repo=fedora --repo=updates --setopt=install_weak_deps=False install \
passwd dnf fedora-release vim-minimal
```#### Chroot in rootfs
If you want to start a shell in the new root filesystem you can:
```sh
sudo chroot $ROOTFS /bin/sh
```### Credits
this project started as a fork of [teddyking/ns-process](https://github.com/teddyking/ns-process)
## Extending and reusing rootfs with Overlay FS
After you build `$ROOTFS`:
```sh
export ROOTFS_BASE="$ROOTFS-base"
export CONTAINERFS="$(pwd)/build/rootfs-container"mv $ROOTFS $ROOTFS_BASE
mkdir -pv $ROOTFS $CONTAINERFS
mount -t tmpfs tmpfs $CONTAINERFS
mkdir -pv $CONTAINERFS/{up,work}# note that we are copying the binary inside the 'up' directory
cp ./build/bicr-httpd-example $CONTAINERFS/up/bin/httpdmount -t overlay overlay -o lowerdir=$ROOTFS_BASE,upperdir=$CONTAINERFS/up/,workdir=$CONTAINERFS/work/ $ROOTFS
# run container
./build/bicr-run httpd
```Overlay FS applies everything inside `$CONTAINERFS` on top of `$ROOTFS_BASE` and makes accessible via `$ROOTFS` so you can `chroot` in it as per usual.
Needless to say you can have many `$CONTAINERFS` on top of a single base rootfs.If you change the base root filesystem or the container FS, you would need to remount so changes can be visible in $ROOTFS.