部署容器组时如何运行多个命令? [英] How do I run multiple commands when deploying a container group?

查看:119
本文介绍了部署容器组时如何运行多个命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用模板 https://docs.microsoft.com/zh-cn/azure/templates/microsoft.containerinstance/2018-10-01/containergroups

它具有命令参数,但是它只是一个字符串并运行一个命令。我想在部署时运行多个命令。

It has command parameter, but it is just a string and runs one command. I would like to run multiple commands when deploying. Is it possible?

如果没有,是否可以使用PowerShell在容器部署后对容器运行这些命令?

If not, is there a way to run those commands to the container after it has been deployed, using PowerShell?

我的用例:
我需要Azure中的SFTP服务器,以便客户能够向我们发送数据。然后,我使用Logic App进行轮询。

My usecase: I need a SFTP server in Azure for customers to be able to send us data. I then poll that with a Logic App.

我做了什么:
我发现此模板非常适合我的需求,因为它更易于轮询Azure存储文件共享。

What I have done: I found this template to be good for my needs, as it is easier to poll Azure Storage File Share.

https://github.com/Azure/azure-quickstart-templates/blob/master/201-aci-sftp-files

我的问题是我有多个用户。每个人都需要自己的用户名/密码以及该文件中的文件共享或子目录。我也无法理解如何通过环境变量配置多个用户。我试图用;分隔它们。它可以部署,但是服务器根本不响应请求。

My problem is I have multiple users. Everyone needs their own username/password and their own file share or sub-directory in that share. I also can't understand how to configure multiple users through the environment variable. I tried separating them with ;. It deploys, but the server doesn't respond to requests at all.

我可以部署多个容器,每个用户一个,但这听起来并不好。

I can deploy multiple containers, one for each user, but that doesn't sound like a good idea when the number of customers rises.

推荐答案

不幸的是,您似乎无法一次运行多命令。请参阅 ACI的exec命令的限制

Unfortunately, it seems that you cannot run multi-command in one time. See the Restrictions of the exec command for ACI:


Azure容器实例当前支持使用az容器exec启动单个
进程,并且您不能传递命令参数。
例如,您不能链接sh -c中的命令 echo FOO&& echo
BAR,或执行echo FOO。

Azure Container Instances currently supports launching a single process with az container exec, and you cannot pass command arguments. For example, you cannot chain commands like in sh -c "echo FOO && echo BAR", or execute echo FOO.

我建议您创建ACI后,可以运行命令与容器实例创建交互式会话,以连续执行命令。

I suggest that you can run the command to create an interactive session with the container instance to execute command continuously after you create the ACI.

对于Linux:

az container exec -g groupName -n containerName- exec命令 / bin / bash

对于Windows:

az容器exec -g groupName -n containerName --exec命令 cmd.exe

这篇关于部署容器组时如何运行多个命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆