Tell HN: Slim 2: Originate VM from Dockerfile, boots in seconds (+macOS M1/Hyper-V)

49
Tell HN: Slim 2: Originate VM from Dockerfile, boots in seconds (+macOS M1/Hyper-V)

slim will manufacture 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 ends up in a real VM that can boot straight, while the utilization of very little sources—all with a pair of traces in a Dockerfile.

The exercise of slim

The next are a pair of programs that that you would be in a position to well perhaps perhaps also exercise slim to manufacture VM photos.

Construct a Ubuntu Focal Cloud Uncooked VM Image

  1. Present a Dockerfile photos/ubuntu-20.04-cloud-init
FROM ubuntu: 20.04 AS kernel
RUN lawful-glean replace && 
    lawful-glean install -y linux-virtual && 
    lawful-glean higher-organized

FROM 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-/initrd

RUN lawful-glean replace 
# Wished for configuring server and constructing units.
RUN lawful install cloud-init udev kmod -y
# Whereas you happen to'd need so as to ssh in: 
RUN lawful install openssh-server sudo -y
  1. Extract an initrd, rootfs, and uncompressed kernel.
$ slim manufacture photos/ubuntu-20.04-cloud-init
...
$ ls -lh ~/.slim/registry/ubuntu-20.04-cloud-init
-rw-r--r--  1 cjparnin  workers    16M Jan  2 17: 37 initrd
-rw-r--r--  1 cjparnin  workers   512M Jan  2 19: 24 rootfs
-rw-------@ 1 cjparnin  workers    29M Nov  5 12: 04 vmlinuz
  1. Present a user-records and meta-records file to customise VM.
$ slim cloudinit photos/ubuntu-20.04-cloud-init
...
$ ls -lh ~/.slim/registry/ubuntu-20.04-cloud-init
-rw-r--r--  1 cjparnin  workers   366Ok Jan  2 21: 19 cidata.iso

VM Operating in MAC M1 (arm64).
slim in macos

Originate a custom Alpine RAM handiest VM Image

  1. Present a Dockerfile and custom init script.

Sight photos/alpine3.12-raw.

  1. Construct initrd and kernel.
$ slim manufacture photos/alpine3.12-raw -f initrd
...
$ ls -lh ~/.slim/registry/alpine3.12-raw         
-rw-r--r--  1 cjparnin  workers    22M Jan  2 20: 50 initrd
-rw-r--r--  1 cjparnin  workers   4.6M Dec 28 11: 22 vmlinuz

Originate a Hyper-V VHD Image (Home windows)

The next creates a Ubuntu Focal with cloud-init, however the principal hyper-v kernel modules,
and bootable image for Microsoft’s Hyper-V.

  1. Present a Dockerfile.

Sight photos/ubuntu-20.04-ci-hyperv.

  1. Originate a VHD disk power (1G) with EFI bootable partition.
PS slim manufacture photos/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
  1. Present a user-records and meta-records file to customise VM.
$ slim cloudinit photos/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

Placing in slim

Simply clone this repo, cd slim, and bustle:

npm install
npm hyperlink

# Pull docker photos frail for gadget dependencies.
slim init

You salvage to salvage docker to your gadget.

Be part of the pack! Be part of 8000+ others registered users, and glean chat, scheme groups, put up updates and scheme chums spherical the globe!
www.knowasiak.com/register/

Charlie Layers
WRITTEN BY

Charlie Layers

Fill your life with experiences so you always have a great story to tell