---
title: Lima - macOS 上的 Linux 虚拟机、Docker 容器，像 WSL2 一样
date: 2024-05-29T12:18:45Z
modified: 2024-05-29T12:18:53Z
permalink: "https://www.appinn.com/lima-vm/"
type: post
status: publish
excerpt: ""
categories:
  - macOS
tags:
  - macOS
  - Docker
  - 虚拟机
featured_image: "https://www.appinn.com/wp-content/uploads/2024/05/Appinn-feature-images-2024-05-29T200128.051.jpg"
author: 青小蛙
timestamp: 2024-05-29T12:18:53Z
---

**Lima** 是一款运行在 macOS 上的 Linux 虚拟机，支持文件共享和端口转发，支持 Docker，就像 Windows 系统里自带的虚拟机 WSL2 一样。@[Appinn](https://www.appinn.com/lima-vm.md)

![Lima - macOS 上的 Linux 虚拟机，像 WSL2 一样](https://www.appinn.com/wp-content/uploads/2024/05/Appinn-feature-images-2024-05-29T200128.051.jpg)

以前在 Mac 上想要安装 Linux 虚拟机，至少还要折腾一下是选 PD 还是选 VM，然后下载个 Linux 镜像文件，现在就…

## 第一步：安装 Lima


brew install lima


## 第二步：安装一个 Linux


limactl create appinn


选择模板（系统）后，几分钟就下载并安装好了。

## 第三步：打开 shell


lima


就…很方便。

支持通过模板启动机器，一台虚拟机大概也就几分钟完成。

## 一个例子：启动一个 Docker 容器


limactl start template://docker
export DOCKER_HOST=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock')
docker run -d --name nginx -p 127.0.0.1:8080:80 nginx:alpine


以上命令将启动一个 nginx 容器，并打开本机的 8080 端口

### 支持的 Linux 发行版本

- [`almalinux-8`](https://github.com/lima-vm/lima/tree/master/examples/almalinux-8.yaml): AlmaLinux 8
- [`almalinux-9`](https://github.com/lima-vm/lima/tree/master/examples/almalinux-9.yaml), `almalinux.yaml`: AlmaLinux 9
- [`alpine`](https://github.com/lima-vm/lima/tree/master/examples/alpine.yaml): ☆Alpine Linux
- [`archlinux`](https://github.com/lima-vm/lima/tree/master/examples/archlinux.yaml): ⭐Arch Linux
- [`centos-stream-8`](https://github.com/lima-vm/lima/tree/master/examples/centos-stream-8.yaml): CentOS Stream 8
- [`centos-stream-9`](https://github.com/lima-vm/lima/tree/master/examples/centos-stream-9.yaml), `centos-stream.yaml`: CentOS Stream 9
- [`debian-11`](https://github.com/lima-vm/lima/tree/master/examples/debian-11.yaml): Debian GNU/Linux 11(bullseye)
- [`debian-12`](https://github.com/lima-vm/lima/tree/master/examples/debian-12.yaml), `debian.yaml`: ⭐Debian GNU/Linux 12(bookworm)
- [`fedora`](https://github.com/lima-vm/lima/tree/master/examples/fedora.yaml): ⭐Fedora
- [`opensuse`](https://github.com/lima-vm/lima/tree/master/examples/opensuse.yaml): ⭐openSUSE Leap
- [`oraclelinux-8`](https://github.com/lima-vm/lima/tree/master/examples/oraclelinux-8.yaml): Oracle Linux 8
- [`oraclelinux-9`](https://github.com/lima-vm/lima/tree/master/examples/oraclelinux-9.yaml), `oraclelinux.yaml`: Oracle Linux 9
- [`rocky-8`](https://github.com/lima-vm/lima/tree/master/examples/rocky-8.yaml): Rocky Linux 8
- [`rocky-9`](https://github.com/lima-vm/lima/tree/master/examples/rocky-9.yaml), `rocky.yaml`: Rocky Linux 9
- [`ubuntu`](https://github.com/lima-vm/lima/tree/master/examples/ubuntu.yaml): Ubuntu (same as `default.yaml` but without extra YAML lines)
- [`ubuntu-lts`](https://github.com/lima-vm/lima/tree/master/examples/ubuntu-lts.yaml): Ubuntu LTS (same as `ubuntu.yaml` but pinned to an LTS version)
- [`deprecated/centos-7`](https://github.com/lima-vm/lima/tree/master/examples/deprecated/centos-7.yaml): \[deprecated\] CentOS Linux 7
- [`experimental/gentoo`](https://github.com/lima-vm/lima/tree/master/examples/experimental/gentoo.yaml): \[experimental\] Gentoo
- [`experimental/opensuse-tumbleweed`](https://github.com/lima-vm/lima/tree/master/examples/experimental/opensuse-tumbleweed.yaml): \[experimental\] openSUSE Tumbleweed

### 容器：

- [`apptainer`](https://github.com/lima-vm/lima/tree/master/examples/apptainer.yaml): Apptainer
- [`apptainer-rootful`](https://github.com/lima-vm/lima/tree/master/examples/apptainer-rootful.yaml): Apptainer (rootful)
- [`docker`](https://github.com/lima-vm/lima/tree/master/examples/docker.yaml): ⭐Docker
- [`docker-rootful`](https://github.com/lima-vm/lima/tree/master/examples/docker-rootful.yaml): Docker (rootful)
- [`podman`](https://github.com/lima-vm/lima/tree/master/examples/podman.yaml): Podman
- [`podman-rootful`](https://github.com/lima-vm/lima/tree/master/examples/podman-rootful.yaml): Podman (rootful)
- LXD is installed in the default Ubuntu template, so there is no `lxd.yaml`

### 容器镜像构建器：

- [`buildkit`](https://github.com/lima-vm/lima/tree/master/examples/buildkit.yaml): BuildKit

### 容器编排：

- [`faasd`](https://github.com/lima-vm/lima/tree/master/examples/faasd.yaml): [Faasd](https://docs.openfaas.com/deployment/faasd/)
- [`k3s`](https://github.com/lima-vm/lima/tree/master/examples/k3s.yaml): Kubernetes via k3s
- [`k8s`](https://github.com/lima-vm/lima/tree/master/examples/k8s.yaml): Kubernetes via kubeadm
- [`experimental/u7s`](https://github.com/lima-vm/lima/tree/master/examples/experimental/u7s.yaml): [Usernetes](https://github.com/rootless-containers/usernetes): Rootless Kubernetes

Optional feature enablers:

- [`vmnet`](https://github.com/lima-vm/lima/tree/master/examples/vmnet.yaml): ⭐enable [`vmnet.framework`](https://github.com/lima-vm/lima/tree/master/docs/network.md)
- [`experimental/9p`](https://github.com/lima-vm/lima/tree/master/examples/experimental/9p.yaml): \[experimental\] use 9p mount type
- [`experimental/virtiofs-linux`](https://github.com/lima-vm/lima/tree/master/examples/experimental/9p.yaml): \[experimental\] use virtiofs mount type for Linux
- [`experimental/armv7l`](https://github.com/lima-vm/lima/tree/master/examples/experimental/armv7l.yaml): \[experimental\] ARMv7
- [`experimental/riscv64`](https://github.com/lima-vm/lima/tree/master/examples/experimental/riscv64.yaml): \[experimental\] RISC-V
- [`experimental/net-user-v2`](https://github.com/lima-vm/lima/tree/master/examples/experimental/net-user-v2.yaml): \[experimental\] user-v2 network to enable VM-to-VM communication without root privilege
- [`experimental/vnc`](https://github.com/lima-vm/lima/tree/master/examples/experimental/vnc.yaml): \[experimental\] use vnc display and xorg server

带星星 ⭐ 的是稳定性比较好的系统。

## 获取

- [官网](https://lima-vm.io/)
- [文档](https://lima-vm.io/docs/)

---

原文：https://www.appinn.com/lima-vm/

## Topics

**分类目录:** [macOS](https://www.appinn.com/category/mac/?output_format=md)

**标签:** [Docker](https://www.appinn.com/tag/docker/?output_format=md), [虚拟机](https://www.appinn.com/tag/%e8%99%9a%e6%8b%9f%e6%9c%ba/?output_format=md)