What i want do is create container and create file inside the container. so thought first try would be to list files so i ran.
kubectl run test-nginx --restart=Never --image nginx:alpine -- /bin/sh -c "ls"
.
It works as expected. Next would be kubectl run test-nginx --restart=Never --image nginx:alpine -- /bin/sh -c "touch index.txt"
. But it fails saying Error
. why it cant just create file inside the container. Am i missing something ?
Use /bin/sh
not /bin/bash
As of this writing, the nginx:alpine image from dockerhub doesn't have /bin/bash.
I'm not sure why kubectl run test-nginx --restart=Never --image nginx:alpine -- /bin/bash -c "ls"
works for you, unless the image is a custom one..