我有一个ECS任务设置,当使用命令覆盖 ls 时,会使用我的CloudWatch日志流产生预期结果: test.py 。我的脚本 test.py 需要一个参数。我想知道如何使用命令覆盖使用python3(存在于我的容器中)执行此脚本。基本上,我想执行命令:
python3 test.py hello
我该怎么做?
答案 0 :(得分:1)
以下是我做类似的事情:
在docker构建文件中,将要运行的命令作为最后一条指令运行。在你的情况下:
CMD ["python3", "test.py"]
为了使其更具可扩展性,请使用环境变量。例如,做类似的事情:
#include <iostream>
using namespace std;
struct node{
public:
node(int n){
node* ptr = this;
data = 0;
for (int t=0; t<n-1; t++){
ptr -> next = new node(1);
ptr = ptr -> next;
ptr -> data = 0;
}
ptr -> next = NULL;
}
node(node &obj){
delete next;
node* ptr = this;
node* optr = &obj;
while (true){
ptr -> data = optr -> data;
optr = optr -> next;
if (optr == NULL) break;
ptr -> next = new node(1);
ptr = ptr -> next;
}
}
~node(){
if (next != NULL) delete next;
}
private:
double data;
node* next;
};
void func(node a){
node b(1);
b = a;
}
int main(){
node v(3);
func(v);
}
但是,让参数来自您传递到任务中容器定义的环境变量。