Question

How can I unzip a file in a mongodb container installed using helm in a DO K8 cluster ?

Posted February 15, 2020 758 views
MongoDBKubernetes

I was able to copy the mongodb dump zip file on to the pod but I am not able to unzip it.
I tried to install unzip package but apt-get is throwing an error:
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

And is there way to get root access to the pod shell ?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

Hello,

In order for you to get root access to the container that is running inside a pod on the Managed Kubernetes cluster, your container needs to be running as the root user.

What you could do instead is, while building your Docker image you could install the unzip command, that way it would be available once you start the container. To do that you just need to add the following to your Dockerfile:

RUN apt update -y && \
apt install unzip -y

Hope that this helps!
Regards,
Bobby

Another approach you could take to not affect your image would be to have it already extracted locally to some dir locally, then use kubectl cp command to copy the contents of that directory to the pod.

I do want to point out that unless where you’re copying the data to is backed by persistent storage all data copied to a pod will be lost on a container restart.

Regards,

John Kwiatkoski
Senior Developer Support Engineer - Kubernetes

Submit an Answer