SnowConvert AI - How to Use SnowConvert AI with Docker¶
依赖关系¶
必须在计算机上安装以下依赖项:
Docker desktop (https://docs.docker.com/desktop/windows/install/)
Visual Code (https://code.visualstudio.com/download)
Visual Code 中的 Docker 扩展 (https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker)
步骤¶
创建镜像配置文件¶
使用以下内容创建一个名为 “Dockerfile”(无扩展名) 的文件。此配置将用于构建 Docker 镜像。
When using the Ubuntu (https://hub.docker.com/_/ubuntu) image to run the SnowConvert AI CLI for Linux a couple of dependencies must be added to the Dockerfile in order to activate the license, for this purpose System.Globalization.Invariant (https://docs.microsoft.com/en-us/dotnet/core/run-time-config/globalization) must be turned ON and the OpenSSL must be installed to be able to establish an HTTPS connection for the license validation.
除了依赖项安装外,第二行(COPY 命令)还用于将文件从本地计算机复制到镜像中。在这种情况下,snowCLI 文件(与 Dockerfile 位于同一文件夹中)将被复制到镜像内的 /dockerDestinationFolder 中。
构建镜像¶
启动 Docker Desktop 应用程序。
打开 “Dockerfile” 所在的可视化代码。如果之前安装过 Visual Code 的 Docker 扩展程序,则 “Dockerfile” 会被 Visual Code 自动识别为 docker 配置文件。右键点击“Dockerfile”,然后点击 “Build image...”

这将提示在 Visual Code 的顶部为镜像命名。

使用任何想要的名称然后点击 “Enter”。 这会导致 Docker 通过提取 Ubuntu 镜像、安装依赖项、复制指定文件来设置容器。等待终端处理完成。看到这样的消息后,就表示镜像已成功构建。
运行镜像¶
在“Images”选项卡中转到 Docker Desktop,然后在最近创建的镜像上点击“run”。

返回 Visual Code,然后转到“Docker”选项卡。您应该在 Containers 下看到刚刚运行的图像。您可以将其展开并浏览文件目录。

连接到容器¶
最后,如果右键点击正在运行的容器并点击 “Attach shell”,将能够连接到终端中的容器并使用所有您喜欢的命令。

您应该在此处看到配置文件中的 COPY 命令指定要复制的个人文件。