> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-integration/troubleshooting-and-resources/ci-articles-and-faqs/articles/kaniko-container-runtime-error.md).

# Kaniko container runtime error

## Conditions <a href="#conditions" id="conditions"></a>

* Module: Harness CI
* Environment:
  * Infrastructure: Kubernetes
  * OS: Linux
* Stage: Build
* Step: Build and Push

## Problem <a href="#problem" id="problem"></a>

While building and pushing an image to a Docker registry, you get a `kaniko container runtime error`, such as:

```
kaniko should only be run inside of a container, run with the --force flag if you are sure you want to continue
exit status 1
```

![](https://4226796345-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqKtVmwAGTfGQS1MVC97G%2Fuploads%2Fgit-blob-88fe7bda3370ec4a4a349fa1b452ebb4b978c83c%2Fkb1-img1.png?alt=media)

## Solution <a href="#solution" id="solution"></a>

This error can be resolved by adding a Docker container environment variable. To do this, add a [stage variable](/continuous-integration/use-harness-ci/use-harness-ci/set-up-build-infrastructure/ci-stage-settings.md#advanced-stage-variables) named `container` with the value `docker`.

You can [add stage variables](/harness-ai/use-harness-platform/pipelines/add-a-stage.md#stage-variables) in the Build stage settings, in the YAML editor, or in the pipeline's **Variables** list.

To add a variable to the pipeline's variables list:

1. Select **Variables** on the right side of the Pipeline Studio.

   ![](https://4226796345-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqKtVmwAGTfGQS1MVC97G%2Fuploads%2Fgit-blob-7a0bf3584a0ee4877468f95fbb3da1b840de462c%2Fkb1-img2.png?alt=media)
2. Locate the stage where you have the **Build and Push** step.
3. Next to **Stage Variables**, select **Add Variable**, and configure the variable as follows:

   * Type: String
   * Name: `container`
   * Value: `docker`

   ![](https://4226796345-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqKtVmwAGTfGQS1MVC97G%2Fuploads%2Fgit-blob-befefb9fdeca0ed19aab75df8fc6fad63640aa99%2Fkb1-img3.png?alt=media)
4. Select **Save**.
5. Select **Apply Changes**.

{% @harness-feedback/feedback %}
