1

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
  • 131
  • 1
  • 4

1 Answers1

2

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!.

ItsaMeTuni
  • 131
  • 1
  • 4