触摸命令中的错误

时间:2018-03-27 09:43:18

标签: linux unix docker

我正在创建docker图像,我需要在浏览器中自动打开jenkins页面,因为我需要将我的主机系统(windows)〜/ .ssh / id_rsa.pub放到〜/ .ssh / authorized_keys。经过多次网站参考,我试过这段代码

ADD http://mirrors.jenkins.io/war-stable/2.107.1/jenkins.war /opt/jenkins.war
RUN chmod 644 /opt/jenkins.war
ENV JENKINS_HOME /jenkins

# configure the container to run jenkins, mapping container port 8080 to that host port
ENTRYPOINT ["java", "-jar", "/opt/jenkins.war"]
EXPOSE 8080

RUN mkdir /jenkins/
RUN echo 2.107.1 > /jenkins/jenkins.install.UpgradeWizard.state
RUN echo 2.107.1 > /jenkins/jenkins.install.InstallUtil.lastExecVersion

RUN apt-get install -y sudo \
 adduser admin \
 echo "admin ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/admin \
 chmod 0440 /etc/sudoers.d/admin \
 su - admin -c "touch me"

CMD ["su", "-", "admin", "-c", "/bin/bash"]

    enter code here

RUN mkdir ~/.ssh \
 chmod 700 ~/.ssh \
 touch ~/.ssh/authorized_keys \
 chmod 600 ~/.ssh/authorized_keys \
 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys 
RUN ssh -v ********@192.168******* 'DISPLAY=:0 start http://192.168******:8080'

当我尝试构建图像时,我收到此错误

Step 19/22 : RUN apt-get install -y sudo  adduser admin  echo "admin ALL=(root)
NOPASSWD:ALL" > /etc/sudoers.d/admin  chmod 0440 /etc/sudoers.d/admin  su - admi
n -c "touch admin"
 ---> Running in bec9f6cc1c7a
E: Opening configuration file touch admin - ifstream::ifstream (2: No such file
or directory)
The command '/bin/sh -c apt-get install -y sudo  adduser admin  echo "admin ALL=
(root) NOPASSWD:ALL" > /etc/sudoers.d/admin  chmod 0440 /etc/sudoers.d/admin  su
 - admin -c "touch me"' returned a non-zero code: 100
  1. 有人可以帮助纠正错误
  2. 下一步要完成的程序 我想知道什么是“su - admin -c”触摸我“”行做?????

1 个答案:

答案 0 :(得分:1)

更好的方法可以是:

RUN apt-get install -y sudo \
 adduser admin \
 echo "admin ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/admin \
 chmod 0440 /etc/sudoers.d/admin 

USER admin
RUN touch me
CMD ["/bin/bash"]