How to just run k6 in docker container?

Quick question:
I want to run my k6 tests in our CI/CD Build, we don’t use the cloud we just want the docker container to have k6 so it can run the tests we have implemented, this way developers can run the tests locally as well without installing k6.

we run docker using dockerfile, dockercompose and Make in our builds.

All examples of docker I can find are integrated with other things influxdb and grafana.
Does anyone have a simple docker compose yml that I can look at without that stuff?

In, there’s a Docker tab for all usage examples. You don’t even need docker-compose, plain docker run is enough.

1 Like

I saw that information, and it is helpful but we run docker using dockerfile, dockercompose and Make in our builds. That is why I am looking for a plain jane docker-compose.yml. I guess I just need to know what ports are used and need to be open.

Unless you want to use the k6 REST API, you don’t need to have a port open (and if you do, it’s 6565 by default, configurable with the --address CLI flag). I am not sure why exactly you want to use docker-compose instead of plain docker run, though I guess defining volumes for your scripts might help.

No ports needed. Here is a minimal docker-compose.yml, without all the bells and whistles:

version: '3.4'
    image: loadimpact/k6:latest
    command: run /test.js
      - ./test.js:/test.js
1 Like

Hey simme,

I have a directory called load-tests/k6 where the script that I want to run is:

I also want to use the config.json

can you help with the setup of the docker compose to work with this setup… not sure what the volume should be??