I'm trying to run some tests using k6 on my project running on docker.
I added this to my docker-compose.yml :
k6:
image: loadimpact/k6:latest
command: run /test.js
volumes:
- ./tests/test.js:/test.js
It runs my test when I start the project with docker-compose up
.
But then the k6 container stops, I want to keep it running so I can do something like docker exec -it k6_container run test2.js
How to achieve this ? Is there a cleaner way to run tests ?
I managed to run the tests but I had to install k6 on my PC, since I'm working with a team I want to add it to the dockerized project.
Thank you
You can docker-compose run
a new container with an alternate command; for example
docker-compose run --rm k6 run ./test2.js
Containers aren't expensive to start up, and if your test results are written to either the console or the bind-mounted directory, there shouldn't be a difference between reusing the same container or starting a new one.