I am trying to install and build one file using maven in Dockerfile, but getting an error mvn not found...
I referred to some articles but I did not find anything
can anyone please help me to why I am getting this and how to solve this?
my code
FROM ubuntu:latest
MAINTAINER ganeshthirumani
RUN apt-get update && apt-get install -y wget
ARG USER_HOME_DIR="/root"
#create a dir foe maven in opt
RUN mkdir /opt/maven
RUN mkdir /usr/share/maven
#RUN mkdir /usr/share/maven
#dwnl maven using link in tmp
RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz -O /tmp/maven.tar.gz
#extract the file
RUN cd /tmp && tar xvf maven.tar.gz
#copy the file into opt/maven
RUN cp -R /tmp/apache-maven-3.8.4/* /usr/share/maven/
#RUN cp /opt/files/* /usr/share/maven
# Install OpenJDK-8
RUN apt-get update && \
apt-get install -y openjdk-8-jdk && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
#dwnl zip and move to /opt/files
RUN mkdir /opt/files
RUN wget <this is my zip file> -O /tmp/zip_file.zip
RUN cp /tmp/zip_file.zip /opt/files/
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
RUN mvn clean install -Pdevelopment
#RUN mvn clean install -Pdeployment
CMD ["mvn", "--version"]
and while building...
Sending build context to Docker daemon 97.28kB
Step 1/20 : FROM ubuntu:latest
---> d13c942271d6
Step 2/20 : MAINTAINER ganeshthirumani
---> Using cache
---> 83dbc04930a4
Step 3/20 : RUN apt-get update && apt-get install -y wget
---> Using cache
---> 5a26c629963f
Step 4/20 : ARG USER_HOME_DIR="/root"
---> Using cache
---> fea8fd2bb7f6
Step 5/20 : RUN mkdir /opt/maven
---> Using cache
---> 16a42d6b96c3
Step 6/20 : RUN mkdir /usr/share/maven
---> Using cache
---> 012f68749248
Step 7/20 : RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz -O /tmp/maven.tar.gz
---> Using cache
---> dc498bb88baf
Step 8/20 : RUN cd /tmp && tar xvf maven.tar.gz
---> Using cache
---> be08499a07db
Step 9/20 : RUN cp -R /tmp/apache-maven-3.8.4/* /usr/share/maven/
---> Using cache
---> 7a705ce7213d
Step 10/20 : RUN apt-get update && apt-get install -y openjdk-8-jdk && apt-get clean;
---> Using cache
---> 452e0b263645
Step 11/20 : RUN apt-get update && apt-get install ca-certificates-java && apt-get clean && update-ca-certificates -f;
---> Using cache
---> d65d98457da5
Step 12/20 : ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
---> Using cache
---> b8cacc77d6b0
Step 13/20 : RUN export JAVA_HOME
---> Using cache
---> 1a5918571b65
Step 14/20 : RUN mkdir /opt/files
---> Using cache
---> 66d092f96235
Step 15/20 : RUN wget https://drive.google.com/file/d/1IutshyYqlcTw_MkfC1NJzU9AH8B-W2Fa/view?ts=61f24be4 -O /tmp/zip_file.zip
---> Using cache
---> 7180fa09993b
Step 16/20 : RUN cp /tmp/zip_file.zip /opt/files/
---> Using cache
---> bc861eb85449
Step 17/20 : ENV MAVEN_HOME /usr/share/maven
---> Using cache
---> be97d22b8558
Step 18/20 : ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
---> Using cache
---> 7874ed478f2f
Step 19/20 : RUN mvn clean install -Pdevelopment
---> Running in 5b58132ba431
/bin/sh: 1: mvn: not found
The command '/bin/sh -c mvn clean install -Pdevelopment' returned a non-zero code: 127
and I have seen that the basic directories are:
for maven home MAVEN_HOME /usr/share/maven
for config---> MAVEN_CONFIG "$USER_HOME_DIR/.m2 and where user_home_dir is a root
thanks in advance
Related
I want to create deno docker image using Dockerfile
FROM alpine:latest
WORKDIR /
RUN apk update && \
apk upgrade
RUN apk add curl
RUN curl -fsSL https://deno.land/x/install/install.sh | sh
ENV DENO_INSTALL="/root/.deno"
ENV PATH="${DENO_INSTALL}/bin:${PATH}"
RUN deno --help
But when run docker build -t deno . it shows at last /bin/sh: deno: not found
full output:
Sending build context to Docker daemon 54.78kB
Step 1/8 : FROM alpine:latest
---> f70734b6a266
Step 2/8 : WORKDIR /
---> Using cache
---> b1bbfa810906
Step 3/8 : RUN apk update && apk upgrade
---> Using cache
---> a7761425faba
Step 4/8 : RUN apk add curl
---> Using cache
---> 9099d4f65cb1
Step 5/8 : RUN curl -fsSL https://deno.land/x/install/install.sh | sh
---> Using cache
---> b4ea95c69a73
Step 6/8 : ENV DENO_INSTALL="/root/.deno"
---> Using cache
---> bdc7e1e85e9c
Step 7/8 : ENV PATH="${DENO_INSTALL}/bin:${PATH}"
---> Using cache
---> d35db1caba71
Step 8/8 : RUN deno --help
---> Running in d1ca4e1d0dc6
/bin/sh: deno: not found
The command '/bin/sh -c deno --help' returned a non-zero code: 127
Alpine is missing glibc which is needed for deno to run.
You can use frolvlad/alpine-glibc:alpine-3.11_glibc-2.31 instead and it will work fine.
FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.31
WORKDIR /
RUN apk update && \
apk upgrade
RUN apk add curl
RUN curl -fsSL https://deno.land/x/install/install.sh | sh
ENV DENO_INSTALL="/root/.deno"
ENV PATH="${DENO_INSTALL}/bin:${PATH}"
RUN deno --help
I recommend building a specific deno version, for that, you should use:
curl -fsSL https://deno.land/x/install/install.sh | sh -s v1.0.0
FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.31
ENV DENO_VERSION=1.0.0
# ...
RUN curl -fsSL https://deno.land/x/install/install.sh | sh -s v${DENO_VERSION}
# ...
You can also check deno-docker
I am creating a docker image while building docker it failed to create container on windows and throws the following error. Can anyone help me to overcome this issue
FROM python:3.7
ENV PYTHONUNBUFFERED 1
RUN apt-get update && \
apt-get install -y postgresql-client && \
rm -rf /var/lib/apt/lists/*
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . .
RUN pip install -r requirements.txt
RUN python manage.py makemigrations && python manage.py migrate
EXPOSE 8000
CMD python manage.py runserver 0.0.0.0:8000
Error:
Step 1/9 : FROM python:3.7
---> 0b21994a4758
Step 2/9 : ENV PYTHONUNBUFFERED 1
---> Using cache
---> 925bec50f994
Step 3/9 : RUN apt-get update && apt-get install -y postgresql-client && rm -rf /var/lib/apt/lists/*
Failed to unmarshall layerchain json - invalid character '\x00' looking for beginning of value
The above is the error I am getting. Can anyone help me with this
My problem is that I get an error when running my container on an ARM arch system(RaspberryPI with Raspbian). Image was built on that same Raspberry.
This is my dockerfile:
FROM arm32v7/golang
COPY qemu-arm-static /usr/bin
ENV STATUSOK_VERSION 0.1.1
RUN apt-get update \
&& apt-get install -y unzip \
&& wget https://github.com/sanathp/statusok/releases/download/$STATUSOK_VERSION/statusok_linux.zip \
&& unzip statusok_linux.zip \
&& mv ./statusok_linux/statusok /go/bin/StatusOk \
&& rm -rf ./statusok_linux* \
&& apt-get remove -y unzip git \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
VOLUME /config
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT /docker-entrypoint.sh
I'm able to succesfully build this on a RaspberryPI running Raspbian:
root#raspberrypi:~/armstatusok# docker build . -t armstatusok
Sending build context to Docker daemon 6.656kB
Step 1/7 : FROM arm32v7/golang
---> 8bbfdfd01a06
Step 2/7 : COPY qemu-arm-static /usr/bin
---> Using cache
---> 2572fd1e03a0
Step 3/7 : ENV STATUSOK_VERSION 0.1.1
---> Using cache
---> 25d39a4c6eb5
Step 4/7 : RUN apt-get update && apt-get install -y unzip && wget https://github.com/sanathp/statusok/releases/download/$STATUSOK_VERSION/statusok_linux.zip && unzip statusok_linux.zip && mv ./statusok_linux/statusok /go/bin/StatusOk && rm -rf ./statusok_linux* && apt-get remove -y unzip git && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
---> Using cache
---> bfb1cfa9a985
Step 5/7 : VOLUME /config
---> Using cache
---> 3bfbce28329b
Step 6/7 : COPY ./docker-entrypoint.sh /docker-entrypoint.sh
---> Using cache
---> a1795ca4f40c
Step 7/7 : ENTRYPOINT /docker-entrypoint.sh
---> Using cache
---> d0ce74911ba3
Successfully built d0ce74911ba3
Successfully tagged armstatusok:latest
Next step is to run it, and where I get into trouble:
root#raspberrypi:~/armstatusok# docker run --name=armstatusok -v $PWD:/config armstatusok
/docker-entrypoint.sh: 1: /docker-entrypoint.sh: /go/bin/StatusOk: not found
I went into the container commenting line one of the docker-entrypoint.sh and checked if /go/bin/StatusOk was actually there, and it was.
My docker-entrypoint.sh:
root#raspberrypi:~/armstatusok# cat docker-entrypoint.sh
/go/bin/StatusOk --config /config/config.json
Now my question is, does anybody have a clue where to start? I also tested this dockerfile on x86 arch, and there it worked. I only changed the FROM line to the x86 flavour and removed the COPY qemu-arm-static /usr/bin since that line is there to make it work on ARM arch, according to documentation.
I copied this Dockerfile and start script verbatim and it builds and runs perfectly for me. I get
Config file not present at the given location: /config/config.json give correct file location using --config parameter
because I don't have access to the config file you're using. But the fact I get that message means that StatusOk is running. So I don't know what to suggest.
The only difference I made was to add a shebang #!/bin/sh to the start of the docker-entrypoint.sh file, and ensure it has execute permission, by running ls -al, and if it doesn't have x in the permissions, running chmod +rwx. Don't know if that made any difference as to how the script tried to access /go/bin/StatusOk.
Full docker-entrypoint.sh contents:
#!/bin/sh
/go/bin/StatusOk --config /config/config.json
I am trying configure and run a certain program using Docker. I am a beginner in Docker, so beware of newbie mistakes!
FROM ubuntu:16.04
# create non-root user
ENV USERNAME ros
RUN adduser --ingroup sudo --disabled-password --gecos "" --shell /bin/bash --home /home/$USERNAME $USERNAME
RUN bash -c 'echo $USERNAME:ros | chpasswd'
ENV HOME /home/$USERNAME
RUN apt-get update && apt-get install --assume-yes wget sudo && \
wget https://raw.githubusercontent.com/ROBOTIS-GIT/robotis_tools/master/install_ros_kinetic.sh && \
chmod 755 ./install_ros_kinetic.sh && \
bash ./install_ros_kinetic.sh
RUN apt-get install --assume-yes ros-kinetic-joy ros-kinetic-teleop-twist-joy ros-kinetic-teleop-twist-keyboard ros-kinetic-laser-proc ros-kinetic-rgbd-launch ros-kinetic-depthimage-to-laserscan ros-kinetic-rosserial-arduino ros-kinetic-rosserial-python ros-kinetic-rosserial-server ros-kinetic-rosserial-client ros-kinetic-rosserial-msgs ros-kinetic-amcl ros-kinetic-map-server ros-kinetic-move-base ros-kinetic-urdf ros-kinetic-xacro ros-kinetic-compressed-image-transport ros-kinetic-rqt-image-view ros-kinetic-gmapping ros-kinetic-navigation ros-kinetic-interactive-markers
RUN cd /home/$USERNAME/catkin_ws/src/
RUN git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
RUN git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
USER $USERNAME
WORKDIR /home/$USERNAME
# add catkin env
RUN echo 'source /opt/ros/kinetic/setup.bash' >> /home/$USERNAME/.bashrc
RUN echo 'source /home/$USERNAME/catkin_ws/devel/setup.bash' >> /home/$USERNAME/.bashrc
RUN /bin/bash -c "source /home/ros/.bashrc && cd /home/$USERNAME/catkin_ws && catkin_make"
Gave the following output:
~/m/rosdocker docker build --rm -f "Dockerfile" -t rosdocker:latest .
Sending build context to Docker daemon 5.632kB
Step 1/15 : FROM ubuntu:16.04
---> b0ef3016420a
Step 2/15 : ENV USERNAME ros
---> Using cache
---> 25bf14574e2b
Step 3/15 : RUN adduser --ingroup sudo --disabled-password --gecos "" --shell /bin/bash --home /home/$USERNAME $USERNAME
---> Using cache
---> 3a2787196745
Step 4/15 : RUN bash -c 'echo $USERNAME:ros | chpasswd'
---> Using cache
---> fa4bc1d220a8
Step 5/15 : ENV HOME /home/$USERNAME
---> Using cache
---> f987768fa3b1
Step 6/15 : RUN apt-get update && apt-get install --assume-yes wget sudo && wget https://raw.githubusercontent.com/ROBOTIS-GIT/robotis_tools/master/install_ros_kinetic.sh && chmod 755 ./install_ros_kinetic.sh && bash ./install_ros_kinetic.sh
---> Using cache
---> 9c26b8318f2e
Step 7/15 : RUN apt-get install --assume-yes ros-kinetic-joy ros-kinetic-teleop-twist-joy ros-kinetic-teleop-twist-keyboard ros-kinetic-laser-proc ros-kinetic-rgbd-launch ros-kinetic-depthimage-to-laserscan ros-kinetic-rosserial-arduino ros-kinetic-rosserial-python ros-kinetic-rosserial-server ros-kinetic-rosserial-client ros-kinetic-rosserial-msgs ros-kinetic-amcl ros-kinetic-map-server ros-kinetic-move-base ros-kinetic-urdf ros-kinetic-xacro ros-kinetic-compressed-image-transport ros-kinetic-rqt-image-view ros-kinetic-gmapping ros-kinetic-navigation ros-kinetic-interactive-markers
---> Using cache
---> 4b4c0abace7f
Step 8/15 : RUN cd /home/$USERNAME/catkin_ws/src/
---> Using cache
---> fb87caedbef8
Step 9/15 : RUN git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
---> Using cache
---> d2d7f198e018
Step 10/15 : RUN git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
---> Using cache
---> 42ddcbbc19e1
Step 11/15 : USER $USERNAME
---> Using cache
---> 4526fd7b5d75
Step 12/15 : WORKDIR /home/$USERNAME
---> Using cache
---> 0543c327b994
Step 13/15 : RUN echo 'source /opt/ros/kinetic/setup.bash' >> /home/$USERNAME/.bashrc
---> Using cache
---> dff40263114a
Step 14/15 : RUN echo 'source /home/$USERNAME/catkin_ws/devel/setup.bash' >> /home/$USERNAME/.bashrc
---> Using cache
---> fff611e9d9db
Step 15/15 : RUN /bin/bash -c "source /home/ros/.bashrc && cd /home/$USERNAME/catkin_ws && catkin_make"
---> Running in 7f26a34419a3
/bin/bash: catkin_make: command not found
The command '/bin/sh -c /bin/bash -c "source /home/ros/.bashrc && cd /home/$USERNAME/catkin_ws && catkin_make"' returned a non-zero code: 127
~/m/rosdocker
I need it to run catkin_make (which is on the path set up by .bashrc)
Exit code 127 from shell commands means "command not found". Is .bashrc executable? Normally it is not, probably you want to source it?
source ./home/$USERNAME/.bashrc
As Dan Farrel pointed out in his comment, sourcing the file in a RUN command will only have effect within that shell.
To source .bashrc during the build
If you want it to have effect for later commands in the build you need to run them all in the same RUN statement. In the below .bashrcis sourced in the same shell as catkin_make is run.
RUN . /home/ros/.bashrc && \
cd /home/$USERNAME/catkin_ws && \
catkin_make
To source the .bashrc file when the container starts
What should happen when the container is run using docker runis specified using the ENTRYPOINTstatement. If you just want a plain bash prompt, specify /bin/bash. The shell will be run with the user specified in the USER statement.
So in summary if you add the following to the end of your Dockerfile
USER ros
ENTRYPOINT /bin/bash
When someone runs the container using docker run -it <containerName> they will land in a bash shell as the user ros. Bash will automatically source the /home/ros/.bashrc file and all definitions inside will be available in the shell. (Your RUN statement containing the .bashrc file canbe removed
I am trying to build druid using the docker file provided on the pulsarIO/dockerfiles
But it does not gets build fully and gets stuck at some point:
The Stack looks like this :
shivansh#localhost:~/Documents/Huawei/pulsar/docker-files/pulsarReporting/druid$ sudo sh build
Sending build context to Docker daemon 35.33 kB
Step 1 : FROM ubuntu:14.04
---> 45e5f47e0036
Step 2 : MAINTAINER Xu,Xin <xinxu1#ebay.com>
---> Using cache
---> 46d0ac73c2ed
Step 3 : RUN apt-get update
---> Using cache
---> 7ecac41ee372
Step 4 : RUN apt-get install -y vim less net-tools inetutils-ping curl git telnet nmap socat dnsutils netcat tree htop unzip sudo software-properties-common
---> Using cache
---> be238924e32a
Step 5 : RUN echo 'deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main' > /etc/apt/sources.list.d/java.list && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886 && apt-get update && echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && apt-get install -y oracle-java7-installer
---> Using cache
---> 7b462d5c7b60
Step 6 : RUN wget -q -O - http://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz | tar -xzf - -C /usr/local && ln -s /usr/local/apache-maven-3.2.5 /usr/local/apache-maven && ln -s /usr/local/apache-maven/bin/mvn /usr/local/bin/mvn
---> Using cache
---> 8d93a2bebc76
Step 7 : RUN mvn dependency:get -Dartifact=io.druid:druid-services:0.7.3
---> Using cache
---> 1e3fccd70f5b
Step 8 : RUN curl http://static.druid.io/artifacts/releases/druid-0.7.3-bin.tar.gz | tar xz
---> Using cache
---> 73d092b0fc55
Step 9 : RUN mv druid-0.7.3 druid-services
---> Using cache
---> 278eb7e7f30c
Step 10 : RUN apt-get install -y mysql-server && sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
---> Using cache
---> 9864be2ef7ce
Step 11 : ADD config druid-services/config
---> Using cache
---> 4f3d4b4dd1d7
Step 12 : ADD ./mysql.ddl mysql.ddl
---> Using cache
---> 51b798fa62da
Step 13 : RUN mysqld_safe & mysqladmin --wait=5 ping && mysql < mysql.ddl && mysqladmin shutdown
---> Using cache
---> f7ddfd9fbd3e
Step 14 : WORKDIR /druid-services
---> Using cache
---> cc01a554687d
Step 15 : RUN java -classpath "config/_common:lib/*" io.druid.cli.Main tools pull-deps
---> Running in d8a09c205f3d
Oct 25, 2016 7:23:31 AM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 5.1.3.Final
I cannot understand exactly what the problem is ! And If i try to run the
sudo docker ps -a
command to see the running containers I cannot see the druid one there !
Any help is appreciated !