作者:原来我不帅S_420 | 来源:互联网 | 2023-01-29 06:55
我在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权限.或者我应该安装什么?如果需要,我可以从此图像构建新图像.
1> StephenKing..:
您只能在构建期间执行此操作,如文档中所述.
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用户身份执行任务.