Snowpark Migration Accelerator: 搭配 Docker 使用 SMA

将适用于 Snowpark Migration Accelerator 的 Linux 命令行界面 (CLI) 与 Docker 搭配使用:分步指南

依赖关系

在继续操作前,必须在计算机上安装以下软件:

  • Docker desktop (https://docs.docker.com/desktop/windows/install/)

  • Visual Code (https://code.visualstudio.com/download)

  • Docker Extension in Visual Code (https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker)

步骤

创建镜像配置文件

创建一个名为“Dockerfile”的文件(无需文件扩展名)。该文件将包含构建 Docker 镜像所需的配置。

FROM ubuntu
COPY snowCli /dockerDestinationFolder
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
RUN apt-get update
RUN apt-get install -y ca-certificates openssl

When using the Ubuntu (https://hub.docker.com/_/ubuntu) image to run the Snowpark Migration Accelerator CLI for Linux, you need to add two dependencies to the Dockerfile:

  1. Enable System.Globalization.Invariant (https://docs.microsoft.com/en-us/dotnet/core/run-time-config/globalization) setting

  2. 安装 OpenSSL

这些依赖项是激活许可证和建立安全的 HTTPS 连接以进行许可证验证所必需的。

In addition to installing dependencies, the COPY command copies files from your local machine into the Docker image. For example, the snowCLI file (which must be in the same directory as the Dockerfile) will be copied to /dockerDestinationFolder within the Docker image.

构建镜像

启动 Docker Desktop 应用程序。

打开 Visual Studio Code 并定位到“Dockerfile”。如果您在 Visual Studio Code 中安装了 Docker 扩展,它会自动将 Dockerfile 识别为 Docker 配置文件。要构建 Docker 镜像,请右键单击“Dockerfile”,然后选择“Build image...”

../../../_images/image%28251%29.png

在 Visual Studio Code 顶部出现提示时,输入该镜像的名称。

../../../_images/image%28191%29.png

输入任何名称,然后按“Enter”。Docker 将通过下载 Ubuntu 镜像、安装所需的依赖项和复制指定文件来创建容器。等待终端完成该过程。正确构建镜像后,将显示一条成功消息。

> Executing task: docker build --pull --rm -f "Dockerfile" -t release:Ubuntu "." <

[+] Build completed in 2.0 seconds. All 11 tasks finished successfully.

运行镜像

导航到 Docker Desktop 中的“Images”选项卡,然后点击“Run”按钮,以启动最近创建的镜像。

../../../_images/image%28201%29.png

在 Visual Studio Code 中,导航到“Docker”选项卡。在“Docker”部分下,您将看到最近执行的镜像。点击其旁边的箭头可展开并浏览其文件目录结构。

../../../_images/image%28336%29.png

连接到容器

最后,要访问容器的命令行界面,请右键单击正在运行的容器,并选择“Attach shell”。这将打开一个终端窗口,您可以在其中执行任何需要的命令。

../../../_images/image%28143%29.png

您将在此位置找到您的个人文件。这些文件是之前通过配置文件中的 COPY 命令选定要复制的。