从 azure node sdk 使用 "azure-arm-containerinstance" 时如何正确地将命令传递给容器?

how do you properly pass a command to a container when using "azure-arm-containerinstance" from azure node sdk?

只是在寻找一些关于如何在容器启动时正确调用命令的指导,当通过 azure-arm-containerinstance 包创建它时。关于这个特定部分的文档非常少,我无法在互联网上找到任何示例。

return client.containerGroups
                    .beginCreateOrUpdate(process.env.AZURE_RESOURCE_GROUP, containerInstanceName, {
                        tags: ['server'],
                        location: process.env.AZURE_INSTANCE_LOCATION,
                        containers: [
                            {
                                image: process.env.CONTAINER_IMAGE,
                                name: containerInstanceName,
                                command: ["./some-executable","?Type=Fall?"],
                                ports: [
                                    {
                                        port: 1111,
                                        protocol: 'UDP',
                                    },
                                ],
                                resources: {
                                    requests: {
                                        cpu: Number(process.env.INSTANCE_CPU),
                                        memoryInGB: Number(process.env.INSTANCE_MEMORY),
                                    },
                                },
                            },
                        ],
                        imageRegistryCredentials: [
                            {
                                server: process.env.CONTAINER_REGISTRY_SERVER,
                                username: process.env.CONTAINER_REGISTRY_USERNAME,
                                password: process.env.CONTAINER_REGISTRY_PASSWORD,
                            },
                        ],```

Specifically this part below, is this correct? Just an array of strings? Are there any good examples anywhere? (tried both google and bing) Is this equivalent of docker's CMD ["command","argument"]?

```command: ["./some-executable","?Type=Fall?"],```

关于你的问题,你做的大部分是对的,但也有需要注意的地方。

一个是命令属性将覆盖Dockerfile中的CMD设置。所以如果命令不会一直保持运行,那么当命令执行完时容器会处于终止状态。

第二个是命令属性是一个包含字符串成员的数组,它们将像shell脚本一样执行。所以我建议你可以这样设置:

command: ['/bin/bash','-c','echo $PATH'],

而且你最好保持前两个字符串不变,只改变后面的。

如果您还有其他问题,请告诉我。或者如果它有帮助你可以接受它:-)