-
Driven by yaml file which defines the assembly we want to create:
- kernel (to build bootable vm, stored under /boot) ~> see kernel files info should point to container image which has kernel file (i.e. bzImage) and tar with kernel modules
- init: list of images used for init system (unpacked into root filesystem). In case of LinuxKit system this should bring up containerd and system containers For ease of modification runc and containerd images, which just contain these programs are added here rather than bundled into the init container.
- onboot list of images run before any other images (can be used to configure one shot settings)
- services list of images for long running services which are run with containerd (undefined startup order, thus wait / retry for things such as networking should be built in)
- files can be used to add files inline in the config or from external file (default file mode is 0600)
The main use case is to build an assembly that includes containerd to run a set of containers, but the tooling is very generic.
Create self-contained and immutable images
References
- Play with Docker
- Training integrated with PWD
- Play with Moby
- LinuxKit online meetup
- DockerCon LinuxKit demos
- workshops on security (and capabilities)
Pre-req to demo on AWS:
- aws cli installed and configured for your AWS Account
- Docker for Mac
Use Docker-Machine to create a playground instance and ssh into it when ready
# having aws cli pre-configured.. use docker-machine to create new instance (m3.medium does not provide enough memory to run demo)
docker-machine create --driver amazonec2 --amazonec2-region=ap-southeast-1 --amazonec2-instance-type=m3.xlarge aws-02
docker-machine ssh aws-02
Set up all pre-requirements on the AWS Instance (aws cli, moby and linuxkit)
sudo usermod -a -G docker ubuntu
sudo apt install python-pip -y
pip install awscli
aws configure
export AWS_REGION=ap-southeast-1 #required for linuxkit push
git clone https://github.com/linuxkit/linuxkit.git
cd linuxkit/
make
sudo cp bin/{moby,linuxkit} /usr/local/bin/
moby version && linuxkit version
Create S3 bucket and set up AWS roles for aws demo
export S3_BUCKET=demo-linuxkit-images
aws s3 mb s3://${S3_BUCKET} --region ap-southeast-1
curl -Lo vmimport.sh https://raw.githubusercontent.com/ajeetraina/linuxkit/master/projects/aws/vmimport.sh
sed "s/arn:aws:s3:::linuxkit-images/arn:aws:s3:::${S3_BUCKET}" vmimport.sh
sed -i '/#Change linuxkit-images/d' vmimport.sh
chmod +x vmimport.sh
./vmimport.sh
redisOS - demo
moby build -name redisos examples/redis-os.yml
linuxkit run redisos
pstree
netstat -l
nc localhost 6379
AWS - demo
moby build -output raw -name aws3 examples/aws.yml
linuxkit push aws -bucket ${S3_BUCKET} -timeout 1200 aws.raw
linuxkit run aws aws
Search for the instances created through the AMI specified above: https://ap-southeast-1.console.aws.amazon.com/ec2/v2/home?region=ap-southeast-1#Instances:search=
Open up access to the instance, get public IP and terminate instance...
export INSTANCE_ID=<instance-id>
export SECURITY_GROUP=<security-group_allowing_port_80>
aws ec2 modify-instance-attribute --instance-id $INSTANCE_ID --groups $SECURITY_GROUP
aws ec2 describe-instances --instance-ids $INSTANCE_ID --query "Reservations[].Instances[].PublicIpAddress" --output text
aws ec2 terminate-instances --instance-ids $INSTANCE_ID