docker-images icon indicating copy to clipboard operation
docker-images copied to clipboard

Download Weblogic installer in RUN in order to decrease image size

Open stour opened this issue 10 years ago • 5 comments

Currently Weblogic installer has to be downloaded manually before to build a Weblogic Docker image. The installer file is then copied into the image using a COPY instruction and removed in following RUN instruction. According to Docker best practices copying and removing a file in two different instructions (so two different layers) does not help to keep the image size down. So in order to decrease the image size of about 1 GO it would be better to download fmw_12.2.1.0.0_wls_Disk1_1of1.zip, extract and remove it in one RUN instruction like:

RUN chmod a+xr /u01 && \
    useradd -b /u01 -m -s /bin/bash oracle && \
    echo oracle:oracle | chpasswd && \
    cd /u01 && wget -q "http://download.oracle.com/otn/nt/middleware/12c/1221/fmw_12.2.1.0.0_wls_Disk1_1of1.zip" && \
    $JAVA_HOME/bin/jar xf /u01/$FMW_PKG && cd - && \
    su -c "$JAVA_HOME/bin/java -jar /u01/$FMW_JAR -silent -responseFile /u01/install.file -invPtrLoc /u01/oraInst.loc -jreLoc $JAVA_HOME -ignoreSysPrereqs -force -novalidation ORACLE_HOME=$ORACLE_HOME INSTALL_TYPE=\"WebLogic Server\"" - oracle && \
    chown oracle:oracle -R /u01 && \
    rm /u01/$FMW_JAR /u01/$FMW_PKG /u01/oraInst.loc /u01/install.file

stour avatar May 20 '16 09:05 stour

Thanks, but if we did that, everytime a user wanted to rebuild the image, the download of a reasonably large file (it is no less than 100MB) would have to happen. We rather stick to downloading once and building as many times as you want.

You may choose to squash the image though, if you want to reduce its size.

brunoborges avatar May 20 '16 16:05 brunoborges

This issue is already closed, but I thought I'd also point out that this would bypass the manual license acceptance that is required to download WebLogic from OTN, which is also not acceptable.

Djelibeybi avatar May 20 '16 21:05 Djelibeybi

@brunoborges I will have a look at docker-squash, thanks. I agree that having to download the archive each time isn't an optimal solution too but if you need a smaller image (the archive itself is more than 800 MB) and the duration of the image build isn't a sensitive issue (as for instance you use a nightly job) then you may prefer this solution. One more thing is that it would help to keep the Dockerfile more "portable" as having the Weblogic installer ready in the folder wouldn't be a prerequisite any more. @Djelibeybi I didn't anticipated it in my example above as it's another topic to me but I think that it's also an issue in the Docker world if you cannot wget a file to extract & install it. It means that the build context (the installer file in this case) is huge and the Dockerfile not really portable.

stour avatar May 23 '16 07:05 stour

@stour Unfortunately, we have to follow Oracle legal guidance in this regard, even if it conflicts with Docker best practice.

Djelibeybi avatar May 23 '16 10:05 Djelibeybi

@stour, the way we wrote these Dockerfiles, makes them portable and it does follow Docker best practices. Docker Inc. is aware of the issue with huge layers due to COPY, and they have a feature coming called flatten images. Check PR #22864.

I say the Dockerfile is portable because you can take it (along with WLS binary of course) and build somewhere else. It is even more portable than downloading from the Internet, where some customers may have proxy/firewall issues. :-)

brunoborges avatar May 23 '16 22:05 brunoborges