我的团队继承了一个 AWS ECS 集群,上面运行着多个链接的容器,但没有源代码(是的,我知道......)。我们需要连接到其中一个正在运行的容器并在其中执行一些命令。这是我们的尝试:
- connecting to the container instance , 但没有与集群关联的实例
- using ECS EXEC with AWS Copilot但不清楚我们如何在无法访问用于部署的源代码的情况下连接到集群
我们还能如何连接到在 AWS ECS 上运行的容器?
更新:
我尝试按照示例使用 AWS CLI 访问容器 here ,才发现任务中没有启用execute命令:
An error occurred (InvalidParameterException) when calling the ExecuteCommand operation: The execute command failed because execute command was not enabled when the task was run or the execute command agent isn’t running. Wait and try again or run a new task with execute command enabled and try again.
现在是放弃的好时机吗?
最佳答案
如果创建任务时未启用 exec 命令,并且它在 Fargate 而不是 EC2 中运行,则无法像您尝试的那样连接到它。
ECR 中有 docker 镜像吗?您应该能够检查 ECS 任务定义以查看 Docker 镜像的位置,然后将 Docker 镜像下载到 EC2 服务器或您的本地计算机,此时您应该能够获取这些 Docker 镜像的内容。
关于amazon-web-services - 连接到 AWS ECS 集群中正在运行的容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68102088/