大网数据广告活动
服务器运维问答

AWS ECS CannotStartContainerError: Error response from daemon

· 52CE 我爱测

I'm trying to start a task with a container with the following command: /bin/sh -c "export KAFKA_LISTENERS=\"PLAINTEXT://$$(hostname -i):9092\" && start-kafka.sh" But I'm getting this error when the container tries to start and I…

问题原文

原帖链接 · ItsaMeTuni · CC BY-SA 4.0

I'm trying to start a task with a container with the following command:

/bin/sh -c "export KAFKA_LISTENERS=\"PLAINTEXT://$$(hostname -i):9092\" && start-kafka.sh"

But I'm getting this error when the container tries to start and I have no idea of what might be causing it:

CannotStartContainerError: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/bin/sh -c \\\"export KAFKA_LISTENERS=\\\\\\\"PLAINTEXT://$$(hostname -i):9092\\\\\\\" && start-kafka.sh\\

The weird thing is that the error only happens in AWS, if I create a docker compose file and run it locally everythig works fine.

Any ideas?

Thank you!

已采纳解答

原帖链接 · ItsaMeTuni · CC BY-SA 4.0

After banging my head against the wall for a few days I finally figured it out. It seems AWS console cuts the error message at 255 characters, so I wasn't seeing the full error message. The isse was that when setting the command for the container, AWS will parse it into an array-style CMD. So /bin/bash -c "echo hello!" gets turned into ["/bin/bash -c \"echo hello!\""], which doesn't work. The correct format would be ["/bin/bash, "-c", "echo hello!"]. To accomplish this you just need to separate your command by commas in the AWS Console, so it becomes/bin/bash,-c,echo hello!.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-05-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。