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:
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.
The Docker container provided is an integration of Redis, task-node, and 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 installed on your local machine.
Clone the task environment repository, and you should have a project with a folder structure similar to the one below:
├── .env
├── .env.example
├── .gitignore
├── Dockerfile.k2
├── docker-compose.yaml
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 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. 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:
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).