创建创建虚拟机磁盘文件
qemu-img create -f qcow2 alpine.img 10G
启动虚拟机(挂在iso镜像)
qemu-system-x86_64 -smp 2 -m 4096 \
-drive file=alpine.img,if=virtio \
-netdev user,id=n1,hostfwd=tcp::6379-:6379,hostfwd=tcp::9000-:9000 \
-device virtio-net,netdev=n1 \
-cdrom alpine-virt-3.13.2-x86_64.iso -boot d \
-nographic \
-vnc 0.0.0.0:0
安装操作系统
setup-alpine
安装过程中,所有都选择默认,直接回车;
仓库镜像源,选择tsing清华;
Available disks are:
vda (10.7 GB 0x1af4 )
Which disk(s) would you like to use? (or '?' for help or 'none') [none] vda
The following disk is selected:
vda (10.7 GB 0x1af4 )
How would you like to use it? ('sys', 'data', 'lvm' or '?' for help) [?] sys
系统安装的磁盘,选择 vda
如何使用,选 sys
关机命令
poweroff
启动
qemu-system-x86_64 -smp 4 -m 4096 \
-drive file=alpine.img,if=virtio \
-netdev user,id=n1,hostfwd=tcp::6379-:6379,hostfwd=tcp::9000-:9000 \
-device virtio-net,netdev=n1 \
-nographic \
-vnc 0.0.0.0:0
错误
Bad Signature 处理
# rm /var/cache/apk/*
安装docker
#更新软件源
apk update
#安装 docker
apk add docker
#docker 添加到开机自启:
rc-update add docker boot
#启动 docker 服务
service docker start