Docker Community Forums

Share and learn in the Docker community.

Can't access to myfolder using "cd" : issue building operation


(Marwenb) #1

Hello every one,
I’m working on creating a “Dockerfile” about maven,
It’s looks like this:

 FROM openjdk:8-jdk

ARG MAVEN_VERSION=3.5.3
ARG USER_HOME_DIR="/root"
ARG SHA=b52956373fab1dd4277926507ab189fb797b3bc51a2a267a193c931fffad8408
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries

RUN mkdir -p /usr/share/docker
ADD myfolder /usr/share/docker

RUN mkdir -p  /usr/share/maven /usr/share/maven/ref \
  && curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
  && echo "${SHA}  /tmp/apache-maven.tar.gz" | sha256sum -c - \
  && tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
  && rm -f /tmp/apache-maven.tar.gz \
  && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn \
  && cd /usr/share/docker/myfolder

 ENV MAVEN_HOME /usr/share/maven
 ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"

ADD settings.xml /root/.m2

CMD ["mvn clean package"] 

But when i built it i get this error:

 /bin/sh: 1: cd: can't cd to /usr/share/docker/myfolder

What i should do to resolve this issue?

Thank you for your help.