在 Docker 中运行 Milvus(Windows)
本页演示如何使用 Docker Desktop for Windows 在 Windows 上运行 Milvus。
前提条件
- 安装 Docker Desktop。
- 安装 Windows Subsystem for Linux 2 (WSL 2)。
- 安装 Python 3.8+。
在 Docker 中运行 Milvus
Milvus 提供了一个安装脚本,可以将其安装为 Docker 容器。在 Microsoft Windows 上安装 Docker Desktop 后,您可以在管理员模式下从 PowerShell 或 Windows 命令提示符以及 WSL 2 访问 Docker CLI。
从 PowerShell 或 Windows 命令提示符
如果您更熟悉 PowerShell 或 Windows 命令提示符,命令提示符如下。
-
右键单击 Docker Desktop 并选择以管理员身份运行以管理员模式打开。
-
下载安装脚本并将其保存为
standalone.bat
。C:\>Invoke-WebRequest https://raw.githubusercontent.com/milvus-io/milvus/refs/heads/master/scripts/standalone_embed.bat -OutFile standalone.bat
-
运行下载的脚本以将 Milvus 作为 Docker 容器启动。
C:\>standalone.bat start
Wait for Milvus starting...
Start successfully.
To change the default Milvus configuration, edit user.yaml and restart the service.运行安装脚本后:
- 一个名为 milvus-standalone 的 Docker 容器已在端口 19530 启动。
- 一个嵌入式 etcd 与 Milvus 一起安装在同一容器中,并在端口 2379 提供服务。其配置文件映射到当前文件夹中的 embedEtcd.yaml。
- Milvus 数据卷映射到当前文件夹中的 volumes/milvus。
您可以使用以下命令管理 Milvus 容器和存储的数据。
# 停止 Milvus
C:\>standalone.bat stop
Stop successfully.
# 删除 Milvus 容器
C:\>standalone.bat delete
Delete Milvus container successfully. # 容器已被移除。
Delete successfully. # 数据已被移除。
从 WSL 2
如果您更喜欢在 Windows 上使用 Linux 命令和 shell 脚本启动 Milvus,请确保您已安装了 WSL 2 命令。有关如何安装 WSL 2 命令的详细信息,您可以参考这篇 Microsoft 文章。
-
启动 WSL 2。
C:\>wsl --install
Ubuntu already installed.
Starting Ubuntu... -
下载安装脚本
# 下载安装脚本
$ curl -sfL https://raw.githubusercontent.com/milvus-io/milvus/master/scripts/standalone_embed.sh -o standalone_embed.sh
# 启动 Docker 容器
$ bash standalone_embed.sh start -
将 Milvus 作为 Docker 容器启动。
$ bash standalone_embed.sh start
Wait for Milvus Starting...
Start successfully.
To change the default Milvus configuration, add your settings to the user.yaml file and then restart the service.您可以使用以下命令管理 Milvus 容器和存储的数据。
# 停止 Milvus
$ bash standalone_embed.sh stop
Stop successfully.
# 删除 Milvus 数据
$ bash standalone_embed.sh stop
Delete Milvus container successfully.
Delete successfully.
使用 Docker Compose 运行 Milvus
在 Microsoft Windows 上安装 Docker Desktop 后,您可以在管理员模式下从 PowerShell 或 Windows 命令提示符访问 Docker CLI。您可以在 PowerShell、Windows 命令提示符或 WSL 2 中运行 Docker Compose 来启动 Milvus。
从 PowerShell 或 Windows 命令提示符
-
右键单击 Docker Desktop 并选择以管理员身份运行以管理员模式打开。
-
在 PowerShell 或 Windows 命令提示符中运行以下命令,下载 Milvus 单机版的 Docker Compose 配置文件并启动 Milvus。
# 下载配置文件并将其重命名为 docker-compose.yml
C:\>Invoke-WebRequest https://github.com/milvus-io/milvus/releases/download/v2.4.15/milvus-standalone-docker-compose.yml -OutFile docker-compose.yml
# 启动 Milvus
C:\>docker compose up -d
Creating milvus-etcd ... done
Creating milvus-minio ... done
Creating milvus-standalone ... done根据您的网络连接,下载 Milvus 安装的镜像可能需要一段时间。一旦名为 milvus-standalone、milvus-minio 和 milvus-etcd 的容器启动,您可以看到:
- milvus-etcd 容器不向主机暴露任何端口,并将其数据映射到当前文件夹中的 volumes/etcd。
- milvus-minio 容器使用默认认证凭据在本地服务端口 9090 和 9091,并将其数据映射到当前文件夹中的 volumes/minio。
- milvus-standalone 容器使用默认设置在本地服务端口 19530,并将其数据映射到当前文件夹中的 volumes/milvus。
如果您已安装 WSL 2,也可以调用 Linux 版本的 Docker Compose 命令。
从 WSL 2
该过程类似于在 Linux 系统中使用 Docker Compose 安装 Milvus。
-
启动 WSL 2。
C:\>wsl --install
Ubuntu already installed.
Starting Ubuntu... -
下载 Milvus 配置文件。
$ wget https://github.com/milvus-io/milvus/releases/download/v2.4.17/milvus-standalone-docker-compose.yml -O docker-compose.yml
-
启动 Milvus。
$ sudo docker compose up -d
Creating milvus-etcd ... done
Creating milvus-minio ... done
Creating milvus-standalone ... done
常见问题
如何处理 Docker Engine stopped
错误?
在 Windows 上安装 Docker Desktop 后,如果您的计算机配置不当,可能会遇到 Docker Engine stopped
错误。在这种情况下,您可能需要进行以下检查:
-
检查是否启用了虚拟化。
您可以通过打开任务管理器的性能选项卡来检查是否启用了虚拟化。
如果虚拟化被禁用,您可能需要检查主板固件的 BIOS 设置。在 BIOS 设置中启用虚拟化的方法因主板厂商而异。例如,对于华硕主板,您可以参考这篇文章来启用虚拟化。
然后,您需要重启计算机并启用 Hyper-V。详情请参阅这篇 Microsoft 文章。
-
检查 Docker Desktop Service 是否已启动。
您可以运行以下命令来启动 Docker Desktop Service。
C:\>net start com.docker.service
The Docker for Windows Service service is starting.
The Docker for Windows Service service was started successfully. -
检查 WSL 是否已正确安装。
您可以运行以下命令来安装或更新 WSL 2 命令。
C:\>wsl --update
Checking for updates.
The most recent version of Windows Subsystem for Linux is already installed. -
检查 Docker Daemon 是否已启动。
您需要进入 Docker Desktop 的安装目录并运行
.\DockerCli.exe -SwitchDaemon
来启动 Docker Daemon。C:\>cd "C:\Program Files\Docker\Docker"
C:\Program Files\Docker\Docker>.\DockerCli.exe -SwitchDaemon
Switching to windows engine: Post "http://ipc/engine/switch": open \\.\pipe\dockerBackendApiServer: The system cannot find the file specified. -
检查是否以管理员模式启动了 Docker Desktop。
确保您以管理员模式启动了 Docker Desktop。为此,右键单击 Docker Desktop 并选择以管理员身份运行。
如何处理部署 Milvus 时的 WSL 相关问题?
如果您在从 WSL 2 运行 Milvus 时遇到 WSL 相关问题,您可能需要检查是否按如下方式配置了 Docker Desktop 以使用基于 WSL 2 的引擎:
-
确保在设置 > 常规中勾选了"使用基于 WSL 2 的引擎"。
-
通过转到设置 > 资源 > WSL 集成,从已安装的 WSL 2 发行版中选择要启用 Docker 集成的发行版。
如何处理 Milvus 启动期间提示的 Read config failed
卷相关错误?
To deal with the error prompted during Milvus startup that reads "Read config failed," you need to check whether the volume mounted into the Milvus container is correct. If the volume is correctly mounted into the container, you can use the docker exec
command to go into the container and list the /milvus/configs folder as follows:
What's next
Having installed Milvus in Docker, you can:
-
Check Quickstart to see what Milvus can do.
-
Learn the basic operations of Milvus:
-
Deploy your Milvu cluster on clouds:
-
Explore Milvus WebUI, an intuitive web interface for Milvus observability and management.
-
Explore Milvus Backup, an open-source tool for Milvus data backups.
-
Explore Birdwatcher, an open-source tool for debugging Milvus and dynamic configuration updates.
-
Explore Attu, an open-source GUI tool for intuitive Milvus management.