Permission denied on k6 docker json output

I want to save json output via docker k6.

This works well.
docker run -i -v $(pwd):/ci/ loadimpact/k6:latest run /ci/performance-test.js

But this does not work well.
docker run -i -v $(pwd):/ci/ loadimpact/k6:latest run --out json=/ci/result.json /ci/performance-test.js
time="2021-04-03T04:09:20Z" level=error msg="open /ci/result.json: permission denied"

Do you have any suggestions?

related issues:
Save json when using docker to run k6 - k6 support - k6 community forum Save json when using docker to run k6
I read it, but I don’t solve my issue yet.

This is minimal reproduce.

I tried this: k6 io/blog/integrating-load-testing-with-circleci

Hi @sanemat,

Chances are that the directory you mount has write access only for your user, but k6 runs with a non-root user that has UID 12345 by default.

You can fix that with --user $UID to your arguments.

1 Like

@mstoykov Thanks!

$ docker run -i -v $(pwd):/ci/ --user $UID loadimpact/k6:latest run --out json=/ci/result.json /ci/performance-test.js
it works!

and I can use it on circleci!
https://app.circleci.com/pipelines/github/sanemat/faas-penguin/57/workflows/6d76e983-49f5-49ec-81a6-16e753775aa6/jobs/78/artifacts
This is circleci example:

And I want to update this article :slight_smile: Load testing with CircleCI