Kaniko container runtime error when pushing to a Docker registry
Conditions
- Module: Harness CI
- Environment:
- Infrastructure: Kubernetes
- OS: Linux
 
- Stage: Build
- Step: Build and Push
Problem
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

Solution
This error can be resolved by adding a Docker container environment variable. To do this, add a stage variable named container with the value docker.
You can add 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:
- 
Select Variables on the right side of the Pipeline Studio.  
- 
Locate the stage where you have the Build and Push step. 
- 
Next to Stage Variables, select Add Variable, and configure the variable as follows: - Type: String
- Name: container
- Value: docker
  
- 
Select Save. 
- 
Select Apply Changes.