我在 docker 容器中设置了 Jenkins 服务器。我使用的图像是docker pull jenkins
. 之后,我通过docker exec -it b74d035352ec bash
. 默认用户是jenkins
但我无法切换到 root 并出现以下错误:
jenkins@b74d035352ec:/$ su -
su: must be run from a terminal
运行时出现以下错误sudo
:
$ sudo ls
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
有谁知道如何解决这个问题?我确实需要该容器的 root 权限。或者我应该安装什么?如果需要,我可以从这个图像构建一个新图像。
您只能在构建期间执行此操作,如文档中所述。
FROM jenkins
# if we want to install via apt
USER root
RUN apt-get update && apt-get install -y ruby make more-thing-here
# drop back to the regular jenkins user - good practice
USER jenkins
因此,您必须构建自己的映像才能以root用户身份执行任务。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句