I am trying to run this Dockerfile with distroless image (gcr.io/distroless/static:nonroot). docker build is happening successfully, but docker run -it image_name is giving me error:
2021-07-13T18:16:11.441Z ERROR controller-runtime.client.config unable to get kubeconfig {"error": "could not locate a kubeconfig"}
github.com/go-logr/zapr.(*zapLogger).Error
/go/pkg/mod/github.com/go-logr/zapr@v0.1.0/zapr.go:128
sigs.k8s.io/controller-runtime/pkg/client/config.GetConfigOrDie
/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.4.0/pkg/client/config/config.go:146
main.main
/workspace/main.go:63
runtime.main
/usr/local/go/src/runtime/proc.go:203
Debugging findings
- Keeping distroless image if I am removing last line
ENTRYPOINT ["/manager"]thendocker run -it image_namegiving error as-:docker: Error response from daemon: No command specified. See 'docker run --help'.
This samedocker runcommand working for distroless(with ENTRYPOINT line) but not working with distroless(without ENTRYPOINT line) - I replaced distroless image with
alpine:latest. Here withENTRYPOINT ["/manager"](& withoutUSER nonroot:nonroot) I am seeing same error as aboveERROR controller-runtime.client.config unable to get kubeconfig...BUT without ENTRYPOINT line, I am able to login to container withdocker run -it image_name.
Someone please let me know how to resolve this, so that I can make this dockerfile run with all required configs as in Dockerfile.
NOTE: I am afraid that my egress-operator pod might not run by changing image name, as it can lead to miss any configuration in dockerfile in order to make it run.