Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aditya1404sal/contain-it
This is a simple mock containerization tool written in Go. It mimics the behavior of basic container operations like pulling an image, unpacking it, and running commands within a new namespace
https://github.com/aditya1404sal/contain-it
containers docker rootfs
Last synced: about 1 month ago
JSON representation
This is a simple mock containerization tool written in Go. It mimics the behavior of basic container operations like pulling an image, unpacking it, and running commands within a new namespace
- Host: GitHub
- URL: https://github.com/aditya1404sal/contain-it
- Owner: Aditya1404Sal
- Created: 2024-06-25T18:28:48.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-13T19:09:49.000Z (5 months ago)
- Last Synced: 2024-07-13T20:26:29.608Z (5 months ago)
- Topics: containers, docker, rootfs
- Language: Go
- Homepage:
- Size: 29.7 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Contain-it : A Mock Containerization Tool
# MVP Status : not ready
TODO : Implement Root-fs extractionThis is a simple mock containerization tool written in Go. It mimics the behavior of basic container operations like pulling an image, unpacking it, and running commands within a new namespace. This tool does not fully replicate Docker's functionality but provides a lightweight alternative for educational purposes.
## Features
- Pull Docker images and save them as tar.gz archives.
- Unpack the archives and run commands within new namespaces.
- Use cgroups to limit resources.
- Chroot to the unpacked image root filesystem.## Usage
### Commands
1. **run**: Run a command inside a new container.
```sh
./cnts run
```
Example:
```sh
./cnts run ubuntu /bin/sh
```2. **child**: This is an internal command used by `run`. It sets up the new namespaces and executes the command.
3. **pull**: Pull a Docker image and store it as a tar.gz archive.
```sh
./cnts pull
```
Example:
```sh
./cnts pull ubuntu
```### Pull Script
The `pull` script is a helper bash script to fetch Docker images, export their filesystem, and save it to the `assets` directory.
```sh
#!/bin/bashset -e
defaultImage="hello-world"
image="${1:-$defaultImage}"
container=$(docker create "$image")docker export "$container" -o "./assets/${image}.tar.gz" > /dev/null
docker rm "$container" > /dev/nulldocker inspect -f '{{.Config.Cmd}}' "$image:latest" | tr -d '[]\n' > "./assets/${image}-cmd"
echo "Image content stored in assets/${image}.tar.gz"
```## Building and Running
1. Build the Go program:
```sh
go build -o cnts
```2. Make the `pull` script executable:
```sh
chmod +x pull
```3. Use the commands as described above.
> **Note**: You need to run these commands as root:
> ```sh
> root@device:~# ./cnts run
> root@device:~# ./cnts pull
> ```## Note
This tool is for educational purposes and is not intended for production use. It demonstrates basic containerization concepts like namespaces and cgroups without the complexity and features of full-fledged container runtimes like Docker.