#1542·kaniko

kaniko should only be run inside of a container

Author: valadorCreated Jan 8, 2021Updated May 27, 2025
Labelskind/bugwork-around-availablepriority/p2area/cli

Actual behavior Try to build example and fail "kaniko should only be run inside of a container, run with the --force flag if you are sure you want to continue" Tested with git context, same error. I start example vith k3s in lxc container, unprevileged - error, previleged - vork fine.

Expected behavior Build and "hello"

To Reproduce k3s kubernetes

Additional Information

  • Dockerfile
FROM ubuntu
ENTRYPOINT ["/bin/bash", "-c", "echo hello"]
  • Build Context
apiVersion: v1
kind: PersistentVolume
metadata:
  name: dockerfile
  labels:
    type: local
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  storageClassName: local-storage
  hostPath:
    path: /home/dev/test/src # in src only Dockerfile
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: dockerfile-claim
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 8Gi
  storageClassName: local-storage
---
apiVersion: v1
kind: Pod
metadata:
  name: kaniko
spec:
  containers:
  - name: kaniko
    image: gcr.io/kaniko-project/executor:latest
    args: ["--dockerfile=/workspace/Dockerfile",
            "--context=dir://workspace",
            "--no-push"] 
    volumeMounts:
      - name: dockerfile-storage
        mountPath: /workspace
  restartPolicy: Never
  volumes:
    - name: dockerfile-storage
      persistentVolumeClaim:
        claimName: dockerfile-claim
  • Kaniko Image (fully qualified with digest) gcr.io/kaniko-project/executor:latest
Description Yes/No
Please check if this a new feature you are proposing
  • - [ ]
Please check if the build works in docker but not in kaniko
  • - [ ]
Please check if this error is seen when you use --cache flag
  • - [ ]
Please check if your dockerfile is a multistage dockerfile
  • - [ ]

Source: GoogleContainerTools/kaniko