【笔记】Lima学习笔记

前言

Lima: Linux virtual machines (on macOS, in most cases)(Github

查看所有虚拟机模版

1
limactl start --list-templates

创建虚拟机

--name=<name>:指定虚拟机名称
<machine>:指定虚拟机配置

template://<name>:指定内置模版配置

docker:使用内置的Docker模版配置

<src>.yaml:指定自定义模版配置

1
2
3
4
5
6
7
limactl start --name=<name> <machine>

? Creating an instance "default" [Use arrows to move, type to filter]
> Proceed with the current configuration
Open an editor to review or modify the current configuration
Choose another example (docker, podman, archlinux, fedora, ...)
Exit
  • 通过上下键选择一项进行下一步操作

启动虚拟机

  • 启动已经存在的虚拟机
1
limactl start <name>

停止虚拟机

1
limactl stop <name>

删除虚拟机

1
limactl delete <name>

虚拟机恢复出厂设置

1
limactl factory-reset <name>

进入虚拟机终端

1
limactl shell <name>

通过Lima部署Docker运行时环境

创建Docker虚拟机

--tty=false:不使用交互式终端

1
limactl start --name=docker --tty=false template://docker

创建Docker运行时环境

1
docker context create lima-docker --docker "host=unix:///Users/用户名/.lima/docker/sock/docker.sock"

设置Docker运行时环境

1
docker context use lima-docker

完成