# Testing Locally with Docker

We provide a Docker container that makes task development very seamless and straightforward. We chose to use Docker in order to provide all the required task development resources in a consistent and isolated environment.

Install Docker here:

{% embed url="<https://www.docker.com/>" %}
Docker Install
{% endembed %}

{% hint style="info" %}
Based on the different operating systems, the installation steps might be different. After fully setup the docker follows the steps below to run the task environment.
{% endhint %}

The Docker container provided is an integration of [Redis](https://redis.io/), [task-node](https://gitlab.com/koii-network/task-node), and [K2](https://gitlab.com/koii-network/k2) in one environment. The complete architecture for task development will be configured after running the Docker container. There's no need to clone the K2 repo or run the test validator locally; K2 is automatically configured and a staking wallet is created for you.

### Run the Task Development Environment

To run the task development environment, ensure you have [Docker](https://www.docker.com/get-started/) installed on your local machine.

Clone the [task environment](https://gitlab.com/koii-network/task-environment) repository, and you should have a project with a folder structure similar to the one below:

```
task-environment
├── .env
├── .env.example
├── .gitignore
├── Dockerfile.k2
├── README.md
├── docker-compose.yaml
└── k2-entrypoint.sh

```

The `.env.example` file contains a list of environment variables and their descriptions.

To run the task environment, run the command below:

```
docker compose up --build
```

Following the execution of the command above, three Docker images are created: `redis`, `K2`, and `task-node`. All required dependencies are installed, and the complete stack for task creation is set up for you.

### **Create a Task**

Now that the task environment is set up, you can create a new task. Refer [here](https://docs.koii.network/microservices-and-tasks/task-development-guide/task-development-flow/create-task) to learn how to create a task. Configure your RPC URL to point to the test validator running on Docker, which is [`http://localhost:8899`](http://localhost:8899). Run the command below to change your RPC URL to point to the test validator running on Docker:

```
koii config set --url localhost
```

Run the command below to confirm that it has been set to [`http://localhost:8899`](http://localhost:8899):

```
koii config get
```

After creating a new task, add the task ID to the `TASKS` variable in the task-environment directory. You can add more than one task by separating the IDs with a comma. After adding your task ID(s), you can run `docker compose up --build` again to build the container and run the task(s).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://koii-network.gitbook.io/getting-started/microservices-and-tasks/task-development-kit-tdk/testing-locally-with-docker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
