Search code examples
dockerkubernetesrunc

Unable to install packages after exec-ing into container as root


I am inside a worker node on a GKE cluster.

I am exec-ing into a container as root using the following command

runc --root /run/containerd/runc/k8s.io/ exec -cap CAP_SYS_ADMIN -t -u 0 <container-id> bash

root@<pod-name>:/#
whoami
root

However, attempting to install packages fails as follows

root@<pod-name>:/# apt update
Reading package lists... Done
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (30: Read-only file system)

Is there a way around this?


Solution

  • Error E: List directory /var/lib/apt/lists/partial is missing. - Acquire (30: Read-only file system) states that your container is booted in read only mode and you cannot add or change the contents inside the container.

    There might be many reasons for this similar to the one’s mentioned below, going through them will help you in resolving this issue:

    • Check whether the container image you are using is a read only image by running the image locally. If the image itself is a read only image try to download a new container image with read write access.

    • If you are using some security context in your container deployment manifest file check whether you have set readOnlyRootFilesystem: as true. If this is set as true you cannot add or remove changes to your container. Try to redeploy your container by removing this parameter or setting readOnlyRootFilesystem: parameter as false.

    If you could provide us more details about the container image you are using or the deployment manifest file you are using or any steps for reproducing the issue, it will be helpful to the community members for providing a more accurate answer.

    Also as David maze suggested if you haven't committed the changes made to this container and build a new image out of it, the changes which you made will be lost. Hence it is suggested to use docker file for installing the packages instead of using a container image to build a new image.