RUN中的未知指令l Docker文件

时间:2017-09-23 19:48:18

标签: docker dockerfile docker-build

嗨这是我的Docker文件。我在安装Maven时遇到错误,它无法找到" ln -s"软链接命令。请帮帮我。

# We first will give the base image details for the tag "FROM" OS:Version
FROM centos:latest
#who will maintain the image 
MAINTAINER XYZ <XYZ@gmail.com>


RUN yum install -y httpd curl sed grep egrep fgrep wget git net-tools zip unzip which source openssh-server

#JAVA INSTALLATION
ADD http://www.mediafire.com/file/177sevky311fbdh/jdk-8u144-linux-x64.rpm / 
RUN rpm -ivh jdk-8u144-linux-x64.rpm 
ENV JAVA_HOME="/usr/java/jdk1.8.0_144"  
ENV JRE_HOME="/usr/java/jdk1.8.0_144/jre"

#MAVEN INSTALLATION
ADD https://www.mediafire.com/folder/6b0t6el85gtof/maven /
RUN mv /maven /opt/maven
    ln -s /opt/maven/bin/mvn /usr/bin/mvn && \
    wget http://www.mediafire.com/file/gpg2arhygj0a0wy/maven.sh && \
    mv /maven.sh /etc/profile.d && \
    chmod 755 /etc/profile.d/maven.sh


RUN cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original && \
    chmod a-w /etc/ssh/sshd_config.original && \
    mkdir /var/run/sshd && \
    echo 'root:screencast' | chpasswd && \
    sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config

CMD ["/usr/sbin/sshd, "-D"]
EXPOSE 22 

1 个答案:

答案 0 :(得分:2)

您需要添加&&\以链接RUN命令togethers

否则,Dockerfile将无法将ln解释为Dockerfile command(例如RUNCOPYADD,...)

RUN mv /maven /opt/maven &&\    <============== missing
    ln -s /opt/maven/bin/mvn /usr/bin/mvn && \

或者至少添加第二次运行

RUN mv /maven /opt/maven 
RUN ln -s /opt/maven/bin/mvn /usr/bin/mvn && \
 ^  ...
 |
 --- missing