Running k6 in Amazon ECS

I am trying to get k6 running in Amazon ECS.

I’m building my scripts into a docker image as part of our build pipeline. My dockerfile:

FROM loadimpact/k6:0.26.1
ENV SCRIPT card-payment.js
COPY ./test /test
ENTRYPOINT [] # override the base image so we can run scripts inside the container
CMD ["sh", "-c", "k6 run $SCRIPT"]

When I run this via the docker command line it works as expected and I’m able to pass in the K6 environment variables:

docker run --rm -it -e K6_VUS=2 loadtests:latest

However, when I run the image in ECS with my environment variables set in the task definition, the K6 variables are ignored and my test is always run with 1 VU.

Any idea why this might be the case?

Hmm I’m not very familiar with ECS, but can you try to remove sh out of the CMD definition? Something like CMD ["k6", "run", "$SCRIPT"]?

1 Like

Hi @benfoster,

Is this problem resolved? Does K6 working in ECS?
In ECS, where you put - card-payment.js script or is part of docker image?

The probable reason as to why this is not working is that your last CMD argument will be treated as a single argument. I’d like to fancy a guess that this would work as you’d expect if you were to change:

CMD ["sh", "-c", "k6 run $SCRIPT"]


CMD ["sh", "-c", "k6", "run", "$SCRIPT"]