gpt4 book ai didi

amazon-web-services - 带有 `aws ecs run-task` 后跟 `aws ecs execute-command` 的 Amazon ECS 的 Docker 镜像中的交互式 shell

转载 作者:行者123 更新时间:2023-12-05 05:56:14 26 4
gpt4 key购买 nike

我想在我的 AWS ECS/Fargate 集群上的公共(public) Docker 镜像中启动交互式 shell,以便从集群内部运行网络/连接测试。

似乎官方的方法是使用 aws ecs run-task 然后是 aws ecs execute-command [1][2]

如果可能,我希望使用现有的公共(public) Docker Hub 镜像,而不是构建自定义镜像。

如果我在没有命令或默认命令的情况下运行 do run-task,任务将退出并且 execute-command 将不会对退出的任务起作用。

"Essential container in task exited"

如果我设置 sleep 10000 的 Docker 命令,我会得到:

"CannotStartContainerError: ResourceInitializationError: failed to create new container runtime task: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: \"sleep 10000\": executable file not found in $PATH: unknown",

理想情况下,run-task 和 execute-command 将合并为一个步骤。我不希望后台任务无限期地运行,我希望 shell 以交互方式运行一些命令,在我完成后将其清理干净。我将如何实现这一点?

[1] https://aws.amazon.com/blogs/containers/new-using-amazon-ecs-exec-access-your-containers-fargate-ec2/

[2] https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html

最佳答案

我遇到了同样的问题。我终于能够使用任务定义中的以下命令让容器处于“空闲”状态:

"tail", "-F", "/dev/null"

然后我可以使用交互式 execute-command 连接。

关于amazon-web-services - 带有 `aws ecs run-task` 后跟 `aws ecs execute-command` 的 Amazon ECS 的 Docker 镜像中的交互式 shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69257527/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com