Modularize structure not running on docker

Hi Team,

I’m running a test on my local it working properly, but when i tried to run it on my docker (docker run -i loadimpact/k6 run - <test.js) I’m getting an error saying they can’t find the remote module. Currently all the modules available on same folder.

  1. how to tackle the current situation ?
  2. If we move the modularize the code with different folders, then how can i tackle it ?

Hi @Gerard !

There is a fourm’s post where I explained how to run the k6’s in docker with mounting scripts

If that doesn’t help could you please provide more details about the error that you have?


Hi @olegbespalov

This is my tree structure

When i run a test (cat loginTest.js | docker run -i grafana/k6 run -) i’ll get a message like below

time=“2022-02-25T07:44:13Z” level=error msg="The moduleSpecifier "…/Pages/homePage.js" couldn’t be found on local disk. Make sure that you’ve specified the right path to the file.

Hi @Gerard!

Both commands:

docker run -i loadimpact/k6 run - <test.js


cat loginTest.js | docker run -i grafana/k6 run -

Is just “redirecting” the content of a single file to a k6.

Please try to mount the catalog with the scripts as the docker volume, as I linked in the first answer. That way from the inside container you can get access to all files.


thanks for the quick response. I’m not a docker expert. Can you tell me based on the tree structure i shared. How to mount it and run the test :slight_smile:

So I guess it can be something like:

docker run --rm -v <path to your src>:/scripts loadimpact/k6:latest run /scripts/Test/loginTest.js

So everything that is located in the src will be located inside the container in the folder /scripts/.

Hi @olegbespalov

how to pass the proxy details while running with docker. Normally we are passing like

$env:HTTPS_PROXY=“http://localhost:4128”; k6 run

Hey @Gerard !

Docker has excellent documentation, so you can easily find the answers to such questions.

Just search for the section about environment variables.