当我尝试构建以下docker文件时,出现错误“来自守护程序的错误响应:Dockerfile解析错误行12:未知指令:SUDO”
FROM jenkins
USER root
RUN apt-get -qqy update; apt-get install -qqy sudo
RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers
RUN wget http://get.docker.com/builds/Linux/x86_64/docker-latest.tgz
RUN tar -xvzf docker-latest.tgz
RUN mv docker/* /usr/bin/
USER jenkins
RUN /usr/local/bin/install-plugins.sh junit git git-client ssh-slaves greenballs chucknorris ws-cleanup
sudo mkdir -p /var/jenkins_home
cd /var/jenkins_home
sudo chown -R 1000 /var/jenkins_home
答案 0 :(得分:1)
以下命令不属于Dockerfile语法
sudo mkdir -p /var/jenkins_home
cd /var/jenkins_home
sudo chown -R 1000 /var/jenkins_home
如果要运行它们,请在它们前面添加RUN
。但是好的做法是将文件夹从本地挂载到容器。如果要映射jenkins主文件夹,请在本地系统上创建/var/jenkins_home
文件夹,然后使用-v
选项安装到Docker容器。
您可以按照给定的链接在dockerized jenkins中使用docker:https://medium.com/@manav503/how-to-build-docker-images-inside-a-jenkins-container-d59944102f30