Dockerfile: Multi-stage builds not working and any python3 + alpine + java image readily available

I am containerizing a component. It requires Linux + Python and Java.

Linux + Python – I am using Alpine 3.5 & Python 3.5 image.

Here is my Docker file.


#       Health Monitoring Docker File
#WORKDIR /etc/alternatives
#COPY --from=build  /etc/alternatives/* .
#RUN rm -rf /var/cache/apk/* && 
#    rm -rf /tmp/*
#RUN apk update
#RUN apk add --update --no-cache
#    build-base 
#    openjdk8-jre 
#  && pip install virtualenv 
#  && rm -rf /var/cache/apk/*

#RUN apk update && apk upgrade && 
#    apk add openjdk8 && 
#    mkdir /tmp/tmprt && 
#    cd /tmp/tmprt && 
#    apk add zip && 
#    unzip -q /usr/lib/jvm/default-jvm/jre/lib/rt.jar && 
#    apk add zip && 
#    zip -q -r /tmp/ . && 
#    apk del zip && 
#    cd /tmp && 
#    mv /usr/lib/jvm/default-jvm/jre/lib/rt.jar && 
#    rm -rf /tmp/tmprt /var/cache/apk/* bin/jjs bin/keytool bin/orbd bin/pack200 bin/policytool 
#          bin/rmid bin/rmiregistry bin/servertool bin/tnameserv bin/unpack200

COPY ./jdk-8u201-linux-x64.tar.gz /
RUN tar xf /jdk-8u201-linux-x64.tar.gz
ENV JAVA_HOME=/jdk1.8.0_201/bin

ENV NGDB_HOME /opt/nsn/ngdb
#RUN yum -y install openjdk-8-jdk-headless
#RUN apt-get install openjdk-8-jdk-headless
#COPY ./openjdk-8_8u181-b13.orig.tar.gz /
#RUN tar xf /openjdk-8_8u181-b13.orig.tar.gz
RUN mkdir -p /opt/nsn/ngdb/monitoring/scripts
RUN mkdir -p /opt/nsn/ngdb/monitoring/utils
RUN mkdir -p /var/local/monitoring/output
RUN mkdir -p /var/local/monitoring/work
RUN for directory in boundaryStatus postgresUsersCount backlogHadoop tableCount_Usage Dimension_Count tableCount_Day tableCount_Week tableCount_Month sendSummaryReport; do mkdir -p $directory;done
COPY ./utils/* /opt/nsn/ngdb/monitoring/utils/
COPY ./scripts/* /opt/nsn/ngdb/monitoring/scripts/
COPY ./conf/* /opt/nsn/ngdb/monitoring/conf/
COPY ./postgresql-9.2-1004.jdbc4.jar /opt/nsn/ngdb/monitoring/utils/
RUN mkdir -p /opt/nsn/ngdb/monitoring/python-dependencies
COPY ./html3-1.17.tar.gz /opt/nsn/ngdb/monitoring/python-dependencies
COPY ./ /opt/nsn/ngdb/monitoring/python-dependencies
#RUN tar xf /opt/nsn/ngdb/monitoring/python-dependencies/html3-1.17.tar.gz
#WORKDIR /html3-1.17/
#RUN python /html3-1.17/ install
RUN unzip /opt/nsn/ngdb/monitoring/python-dependencies/
WORKDIR /py4j-
RUN python /py4j- install

But if i try to add Java Image & Python Alpine Image using “FROM”, I am able to get only one thing in my container.

When i searched, i came across Multi stage builds, but when i did like below it is throwing a error “Unknown flag: from”

WORKDIR /etc/alternatives
COPY --from=0 /etc/alternatives/* .

Can some one please help me out?

And addition to this,

I am trying to install py4j as a external module through which i am calling java classes.

i have set WORKDIR and then installation of py4j module goes smooth.

Later if i try to set WORKDIR to other module ex: html, and when i try

RUN python install

It gives error stating “No Such file or Directory”

Can you please help on this?

Source: StackOverflow