【问题标题】:Terraform: How to automate pulling and running docker images from Azure Container RegistryTerraform:如何从 Azure Container Registry 自动拉取和运行 docker 镜像
【发布时间】:2019-01-25 19:14:35
【问题描述】:

我想自动化将 docker 映像从 Azure 容器注册表拉到 Azure VM 的过程。我已经做了以下事情:

  1. 创建了 Azure 容器注册表。
  2. 在 Azure 容器注册表中设置用户名和密码。
  3. 将映像从我的本地计算机推送到 Container Registry。

我已经设置了 terraform 代码来自动构建 Azure VM。我还想包括 docker pull 和 docker run 命令,以便这些任务是自动化的。以下是我想自动化成 terraform 的命令:

sudo docker login --username xxx --password xxx xxx.azurecr.io
sudo docker pull xxx.azurecr.io/xx/xxx
sudo docker run --network=host xxx.azurecr.io/xxx/xxx

任何帮助将不胜感激。谢谢各位!

【问题讨论】:

    标签: docker-image terraform-provider-azure azure-container-registry


    【解决方案1】:

    据我所知,如果你想在 VM 中执行 Docker CLI 命令,你应该先安装 Docker 引擎。

    另外,如果你想在通过 Terraform 创建 VM 后在 VM 中自动运行 Docker CLI 命令,你可以使用VM extension in Terraform。使用命令编写一个 shell 脚本,然后在 VM 扩展中运行它。这是Using Terraform with Azure VM Extensions的例子。

    【讨论】:

    • 查尔斯,谢谢! Azure 映像预加载了 Docker。我将使用 Azure VM 扩展并尝试使 Docker 命令自动化。
    • 太好了。如果没有更多问题并且有帮助,您可以接受它作为答案。
    • @samcoug 还有问题吗?
    • 我暂时没有移动问题。非常感谢查尔斯。
    • @samcoug 如果答案对您有用。然后你可以接受它作为答案。
    猜你喜欢
    • 1970-01-01
    • 2021-03-13
    • 2018-10-31
    • 2019-02-14
    • 2023-02-01
    • 2023-02-10
    • 1970-01-01
    • 1970-01-01
    • 2019-09-25
    相关资源
    最近更新 更多