如何在非root用户运行的容器中安装新软件包

如何在非root用户运行的容器中安装新软件包

本文介绍了如何在非root用户运行的容器中安装新软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在运行中的容器中安装诸如curl之类的简单软件包,但遇到此错误:

I need to install simple packages such as curl inside a running container but I face this error:

~ $ apk add curl
ERROR: Unable to lock database: Permission denied
ERROR: Failed to open apk database: Permission denied

我知道如何在Dockerfile中更改用户,但是我无权访问Docker文件,因此我需要在容器内部或在容器内部打开终端时执行此操作.我尝试使用-user = ,但是没有用:

I know how to chnage the user in a Dockerfile but I don't have access to the docker file and I need to do it while I am inside the container or when opening a terminal inside the container. I tried to use --user= but didn't work:

kubectl exec -n kube-system --user="root" -it tiller-deploy-75f6c87b87-xtpxl /bin/ash
error: auth info "root" does not exist

如何获得root用户访问权限或安装curl?

How I can get root access or install curl?

推荐答案

您的用户更礼貌吗?运行以下命令:

Is your user sudoer?Run this command:

sudo apk add curl

如果上面的命令不起作用,请运行此命令.

And if the above command didn't work, run this command.

docker exec -it CONTAINER_NAME apk add curl

这篇关于如何在非root用户运行的容器中安装新软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:26