5

嗨,这是我的 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 
4

1 回答 1

10

您需要添加一个&&\以将RUN命令链接在一起

否则 Dockerfile 将无法解释lnDockerfile 命令(如RUN, COPY, ADD, ...)

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
于 2017-09-23T19:57:56.670 回答