# Running via docker image

**URL:** <https://community.grafana.com/t/running-via-docker-image/98830>\
**Category:** OSS Support\
**Created:** [January 21, 2022, 1:06am UTC](https://community.grafana.com/t/running-via-docker-image/98830 "2022-01-21T01:06:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BobRuub](https://avatars.discourse-cdn.com/v4/letter/b/a698b9/32.png) [@BobRuub](https://community.grafana.com/u/BobRuub)\
**Post date:** [January 21, 2022, 1:06am UTC](https://community.grafana.com/t/running-via-docker-image/98830/1 "2022-01-21T01:06:48Z")

</div>

HI all,

I’m wanting to run k6 via docker to enable the devs/qa to execute without any local dependencies.

I’m no docker expert ☹ so am struggling getting it working.

Following the guide here [Running k6](https://k6.io/docs/getting-started/running-k6/) I was able to get a simple script working as expected.

However, I have more complex scripts which access other modules, data and config files which are located in sub-directories.

- plugins (e.g. modules uuid.js)
- config (e.g. json files with vu, duration, etc)
- data (csv files for test execution)

I suspect I’ll be having to use the docker -v command but not sure how best to do so.

Any tips?

---

<div class="post-metadata">

**Author:** ![olegbespalov](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/olegbespalov/32/36739_2.png) [@olegbespalov](https://community.grafana.com/u/olegbespalov)\
**Post date:** [January 21, 2022, 5:40pm UTC](https://community.grafana.com/t/running-via-docker-image/98830/3 "2022-01-21T17:40:31Z")

</div>

Hi @BobRuub!

Let me try to help you!

Yes, considering the `docker -run v` is the right direction.

let’s say you have a directory that contains some files:

```bash
tree
.
├── config.json
├── data
│ └── users.json
└── http_get.js

```

Here the config.json is k6’s [config file](https://k6.io/docs/using-k6/options/#config). The `users.json` is just some data file that I will use in the tests. And the http\_get.js is the test script.

If I run the command:

```bash
docker run --rm -v $(pwd):/scripts loadimpact/k6:latest run /scripts/http_get.js

```

It will mount the current directory (what the `pwd` returns) as the `/scripts` inside the container. And execute the following command inside the container.

```bash
k6 run /scripts/http_get.js

```

My http\_get.js can use any resource located in the same directory. Just use a relative path, like:

`const f = open('data/users.json');`

If I want to use the config.json to run my k6, it will look like this:

```bash
docker run --rm -v $(pwd):/scripts loadimpact/k6:latest run --config /scripts/config.json /scripts/http_get.js

```

Let me know if that helps!  
Cheers

---

<div class="post-metadata">

**Author:** ![BobRuub](https://avatars.discourse-cdn.com/v4/letter/b/a698b9/32.png) [@BobRuub](https://community.grafana.com/u/BobRuub)\
**Post date:** [January 23, 2022, 12:40am UTC](https://community.grafana.com/t/running-via-docker-image/98830/4 "2022-01-23T00:40:45Z")

</div>

Awesome, thanks so much.

Doesn’t work that well on my windows machine as directory sharing with docker is a bit patchy but works brilliantly on my mac which is what all the developers use anyway 🙂

---

<div class="post-metadata">

**Author:** ![olegbespalov](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/olegbespalov/32/36739_2.png) [@olegbespalov](https://community.grafana.com/u/olegbespalov)\
**Post date:** [January 25, 2022, 7:56am UTC](https://community.grafana.com/t/running-via-docker-image/98830/5 "2022-01-25T07:56:20Z")

</div>

I’m happy that it helped 😌
