In my experience, when using k3s v1.27.6+k3s1, I found that the runc
command was not available. Instead, I utilized the ctr
command. Here's how you can do it:
Firstly, you need to identify the container ID. This can be done using the following command:
kubectl -n wordpress describe pod <podname> | grep 'Container ID:'
For instance, you might get an output similar to this:
Container ID: containerd://aaff66aaaeca129eab1b8e51ebf391fd59191f41db5540c1e8af65675737073e
Once you have the container ID, you can use the ctr
command to execute commands within the container. Here's an example:
sudo k3s ctr task exec -t --exec-id myshell --user root aaff66aaaeca129eab1b8e51ebf391fd59191f41db5540c1e8af65675737073e bash
In this command, replace aaff66aaaeca129eab1b8e51ebf391fd59191f41db5540c1e8af65675737073e
with your own container ID. This will allow you to execute commands within your specific container.