Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ottomatica/slim
Build and run tiny vms from Dockerfiles. Small and sleek.
https://github.com/ottomatica/slim
docker micro-vm virtualization
Last synced: about 20 hours ago
JSON representation
Build and run tiny vms from Dockerfiles. Small and sleek.
- Host: GitHub
- URL: https://github.com/ottomatica/slim
- Owner: ottomatica
- License: apache-2.0
- Created: 2019-03-30T12:13:56.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T16:56:39.000Z (almost 2 years ago)
- Last Synced: 2025-01-04T16:04:47.700Z (8 days ago)
- Topics: docker, micro-vm, virtualization
- Language: JavaScript
- Homepage:
- Size: 6.35 MB
- Stars: 2,102
- Watchers: 17
- Forks: 52
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-repositories - ottomatica/slim - Build and run tiny vms from Dockerfiles. Small and sleek. (JavaScript)
- awesome-list - slim
README
# slim | ![CI](https://github.com/ottomatica/slim/workflows/CI/badge.svg)
`slim` will build a VM from a Dockerfile. Slim works by building and extracting a rootfs from a Dockerfile, and packaging a corresponding kernel and initrd into a desired image.
This results in a real VM that can boot instantly, while using very limited resources---all with a couple of lines in a Dockerfile.
## Using slim
The following are a few ways you can use slim to build VM images.
### Build a Ubuntu Focal Cloud Raw VM Image
1. Provide a Dockerfile `images/ubuntu-20.04-cloud-init`
```Dockerfile
FROM ubuntu:20.04 AS kernel
RUN apt-get update && \
apt-get install -y linux-virtual && \
apt-get cleanFROM ubuntu:20.04
# Extract the kernel, modules, and initrd
COPY --from=kernel /lib/modules /lib/modules
COPY --from=kernel /boot/vmlinuz-* /vmlinuz
COPY --from=kernel /boot/initrd.img-* /initrdRUN apt-get update
# Needed for configuring server and setting up devices.
RUN apt install cloud-init udev kmod -y
# If you'd like to be able to ssh in:
RUN apt install openssh-server sudo -y
```2. Extract an initrd, rootfs, and uncompressed kernel.
```
$ slim build images/ubuntu-20.04-cloud-init
...
$ ls -lh ~/.slim/registry/ubuntu-20.04-cloud-init
-rw-r--r-- 1 cjparnin staff 16M Jan 2 17:37 initrd
-rw-r--r-- 1 cjparnin staff 512M Jan 2 19:24 rootfs
-rw-------@ 1 cjparnin staff 29M Nov 5 12:04 vmlinuz
```3. Provide a user-data and meta-data file to customize VM.
```
$ slim cloudinit images/ubuntu-20.04-cloud-init
...
$ ls -lh ~/.slim/registry/ubuntu-20.04-cloud-init
-rw-r--r-- 1 cjparnin staff 366K Jan 2 21:19 cidata.iso
```VM Running in MAC M1 (arm64).
![slim in macos](doc/img/macos.png)### Create a custom Alpine RAM only VM Image
1. Provide a Dockerfile and custom init script.
See [images/alpine3.12-raw](images/alpine3.12-raw).
2. Build initrd and kernel.
```bash
$ slim build images/alpine3.12-raw -f initrd
...
$ ls -lh ~/.slim/registry/alpine3.12-raw
-rw-r--r-- 1 cjparnin staff 22M Jan 2 20:50 initrd
-rw-r--r-- 1 cjparnin staff 4.6M Dec 28 11:22 vmlinuz
```### Create a Hyper-V VHD Image (Windows)
The following creates a Ubuntu Focal with cloud-init, but the necessary hyper-v kernel modules,
and bootable image for Microsoft's Hyper-V.1. Provide a Dockerfile.
See [images/ubuntu-20.04-ci-hyperv](images/ubuntu-20.04-ci-hyperv).
2. Create a VHD disk drive (1G) with EFI bootable partition.
```
PS slim build images/ubuntu-20.04-ci-hyperv -f vhd -s 1024
...
PS ls ~/.slim/registry/ubuntu-20.04-ci-hyperv
-a---- 1/2/2022 3:19 PM 738381824 rootfs.vhd
```3. Provide a user-data and meta-data file to customize VM.
```
$ slim cloudinit images/ubuntu-20.04-ci-hyperv
...
$ ls -lh ~/.slim/registry/ubuntu-20.04-ci-hyperv
-a---- 1/1/2022 3:32 PM 374784 cidata.iso
```![slim in hyperv](doc/img/slim-hyperv.png)
## Installing slim
Simply clone this repo, cd slim, and run:
```
npm install
npm link# Pull docker images used for system dependencies.
slim init
```You must have [docker](https://docs.docker.com/install/) on your system.