-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup_DockerVM.sh
73 lines (50 loc) · 1.36 KB
/
Setup_DockerVM.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
echo ""
echo "################################################################"
echo "## ##"
echo "## Setting up Docker... ##"
echo "## ##"
echo "################################################################"
echo ""
_isoName=alpine-virt-3.16.3-x86_64.iso
_alpineIsoUrl=https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/$_isoName
_destinationDir=Setup_DockerVM
_vmSize=64G
_vmName=docker
_etcVmConf=/etc/vm.conf
rcctl enable vmd
rcctl start vmd
cd /opt
mkdir $_destinationDir
cd $_destinationDir
ftp $_alpineIsoUrl
vmctl create -s $_vmSize $_vmName.qcow2
echo `
switch \"uplink\" {
interface bridge0
}
vm \"${$_vmName}\" {
disable
memory 2G
cdrom \"/opt/${$_destinationDir}/${$_isoName}\"
disk \"/opt/${$_destinationDir}/${$_vmName}.qcow2\"
interface {
switch \"uplink\"
locked lladdr fe:e1:ba:d2:02:30
}
}` >> $_etcVmConf
rcctl restart vmd
vmctl start -c -B cdrom $_vmName
# Send keys to console to login to Alpine
stdin < "root"
setup-alpine
# Power off Alpine
poweroff
# TODO: Connect to VM using SSH
apk update
apk add docker
addgroup myself docker
rc-service docker status
rc-update add docker
rc-service docker start
docker run hello-world