Docker-images: NodeJS Project - OracleLinuxSlim, Node Buster and Node Alpine images size comparison

Created on 25 Apr 2020  路  22Comments  路  Source: oracle/docker-images

I am a few days trying to create a Node Alpine image and install Oracle Libs dependencies and I found out that Oracle is not supporting this Linux distribution.

Ok, so I followed this instruction on Oracle Blog https://blogs.oracle.com/opal/dockerfiles-for-node-oracledb-are-easy-and-simple.

There we can see two docker images supported by Oracle. oraclelinux:7-slim and node:12.9.1-buster-slim.

There is no how argue that Alpine images are Slim comparing with any other. However I went through with this comparison:

  • Build NodeJS Project using Oracle Linux 7 Slim Image WITHOUT Oracle Instant Client
  • Build NodeJS Project using Oracle Linux 7 Slim Image WITH Oracle Instant Client
  • Build NodeJS Project using Node12Buster Slim Image WITHOUT Oracle Instant Client
  • Build NodeJS Project using Node12Buster Slim Image WITH Oracle Instant Client
  • Build NodeJS Project using Node12 Alpine Image WITHOUT Oracle Instant Client

I definitely give up trying to find any good solution to install this Oracle Instant Client on Alpine!

Here we go, a size comparison between this images

Screen Shot 2020-04-25 at 12 30 23

Here my compiled Dockerfiles

##################################################################
###### FROM NODE 12 ALPINE IMAGE WIHTOU ORACLE Instant Client
##################################################################

FROM node:12-alpine

WORKDIR /usr/app
COPY . package*.json ./
RUN npm install

# RUN npm t

EXPOSE 3000
CMD ["npm", "run", "start"]

##################################################################
###### FROM NODE 12 BUSTER SLIM IMAGE WITHOUT ORACLE Instant Client
##################################################################

FROM node:12-buster-slim

WORKDIR /usr/app
COPY . package*.json ./
RUN npm install

# RUN npm t

EXPOSE 3000
CMD ["npm", "run", "start"]

##################################################################
###### FROM NODE 12 BUSTER SLIM IMAGE WITH ORACLE IMAGES
##################################################################

FROM node:12-buster-slim

WORKDIR /tmp
RUN apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade && apt-get install -y alien libaio1 wget
RUN wget http://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/getPackage/oracle-instantclient19.3-basiclite-19.3.0.0.0-1.x86_64.rpm
RUN alien -i --scripts oracle-instantclient*.rpm
RUN rm -f oracle-instantclient19.3*.rpm && apt-get -y autoremove && apt-get -y clean

WORKDIR /usr/app
COPY . package*.json ./
RUN npm install

# RUN npm t

EXPOSE 3000
CMD ["npm", "run", "start"]

##################################################################
###### FROM ORACLE LINUX SLIM IMAGE WITHOUT ORACLE Instant Client
##################################################################

FROM oraclelinux:7-slim

RUN yum -y install oracle-nodejs-release-el7 && \
        yum -y install nodejs && \
        rm -rf /var/cache/yum

WORKDIR /usr/app
COPY . package*.json ./
RUN npm install

# RUN npm t

EXPOSE 3000
CMD ["npm", "run", "start"]

##################################################################
###### FROM ORACLE LINUX SLIM IMAGE WITH ORACLE Instant Client
##################################################################

FROM oraclelinux:7-slim

RUN  yum -y install oracle-release-el7 oracle-nodejs-release-el7 && \
     yum-config-manager --disable ol7_developer_EPEL && \
     yum -y install oracle-instantclient19.6-basiclite nodejs && \
     rm -rf /var/cache/yum

WORKDIR /usr/app
COPY . package*.json ./
RUN npm install

# RUN npm t

EXPOSE 3000
CMD ["npm", "run", "start"]

##################################################################
##################################################################

So here is my thoughts, it looks like the smaller image which we can get with Oracle Instant Client is based on OracleLinux7Slim. As a web software engineer I am used to build images for my NodeJS apps based on Alpine because it is VERY slim. Also, I believe others will came with the same solution until facing this Oracle Libs issues.

If we look at NodeJS12 Buster Slim without Oracle Libs, we can see it is 50Mb smaller than Oracle Linux 7 Slim without Oracle Libs.

But after installed these libs, Oracle Linux 7 slim Image became a better alternative when we are looking for a small image size.

My question is, why we cannot get a slim image after install those Oracle Instant Client on NodeJS Buster Slim?

Would be possible to build a Node Buster Image removing any unnecessary Libs to keep it slim?

How hard is to delivery these libs in a Alpine Image?

  • I know there is a license issues which goes against some linux distributions.
Instantclient help wanted question

Most helpful comment

@cjbj we should keep this in mind for any future updates to the official Oracle Instant Client image.

All 22 comments

(For clarity, it would be better to refer to the Oracle Instant Client instead of "Oracle Libs" because folks won't know what "Oracle Libs" means and you're referring to the "Oracle Instant Client").

First a note on Alpine: Alpine uses the musl C compiler (by default) instead of gcc. That's what allows it to be so small, but the trade-off is compatibility. We are unlikely to support the musl compiler and if you add gcc to Alpine, it jumps up in size to match that of other images like Buster.

Is there a reason why you can't use the Oracle Linux 7 based image with Instant Client and Node.js? Seems like the smallest, simplest option.

Also, you should use https URLs in your Dockerfiles, just for additional assurance that you're connecting to an Oracle host when you download packages.

I did a quick test to see if I could reduce your Buster image size and if you replace all your individual RUN directives with this, it comes out a tiny bit smaller than the Oracle Linux version:

RUN apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade && apt-get install -y alien libaio1 wget && \
    wget https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/getPackage/oracle-instantclient19.3-basiclite-19.3.0.0.0-1.x86_64.rpm && \
    alien -i --scripts oracle-instantclient*.rpm && \
    rm -f oracle-instantclient19.3*.rpm && apt-get -y --purge remove alien && \
    apt-get -y autoremove && apt-get -y clean

However, it may be removing too many packages. The problem with using Alien to install an RPM on Debian is that the dependencies for the package are not maintained in the dpkg database. So, while this option may result in a smaller image (in my test, it was 297MB so 4MB smaller than the Oracle Linux image), it may not actually work properly if the Instant Client depends on a library that gets removed.

BTW, it looks like your Node.js application pulls in about 40MB of dependencies. Here's how large my images are with only Node installed:

node12-oraclelinux7-instantclient                    latest              364dc8b54ac6        5 seconds ago       301MB
node12-buster-instantclient-purge                    latest              b4f1f2270984        5 minutes ago       297MB
node12-buster-instantclient                          latest              39b5e4310150        15 minutes ago      609MB

Also, you should use https URLs in your Dockerfiles, just for additional assurance that you're connecting to an Oracle host when you download packages.

About https, I just followed the Christopher blog post instructions. I assume that is a official Oracle instruction, ins't?

About https, I just followed the Christopher blog post instructions. I assume that is a official Oracle instruction, ins't?

Good point. Hey @cjbj, can you please change your blog post to use https? :)

BTW, it looks like your Node.js application pulls in about 40MB of dependencies. Here's how large my images are with only Node installed:

node12-oraclelinux7-instantclient                    latest              364dc8b54ac6        5 seconds ago       301MB
node12-buster-instantclient-purge                    latest              b4f1f2270984        5 minutes ago       297MB
node12-buster-instantclient                          latest              39b5e4310150        15 minutes ago      609MB

for sure my app is in this all images comparison, which is very small nodejs app.

for sure my app is in this all images comparison, which is very small nodejs app.

Your app is not in my comparison. I didn't install any Node.js app or modules, I just installed the base packages. Here's my Dockerfiles for each:

# node12-buster-instantclient-purge
FROM node:12-buster-slim

WORKDIR /tmp
RUN apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade && apt-get install -y alien libaio1 wget && \
    wget https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/getPackage/oracle-instantclient19.3-basiclite-19.3.0.0.0-1.x86_64.rpm && \
    alien -i --scripts oracle-instantclient*.rpm && \
    rm -f oracle-instantclient19.3*.rpm && apt-get -y --purge remove alien && \
    apt-get -y autoremove && apt-get -y clean

CMD ["/bin/bash"]

And Oracle Linux:

# node12-oraclelinux7-instantclient
FROM oraclelinux:7-slim

RUN  yum -y install oracle-release-el7 oracle-nodejs-release-el7 && \
     yum -y install oracle-instantclient19.6-basiclite nodejs && \
     rm -rf /var/cache/yum

CMD ["/bin/bash"]

Given the tiny difference in size between the two, you're better off using the Oracle Linux based image as all the packages are tested by Oracle prior to release. Using the Instant Client on Buster via Alien is not a supported installation method.

(For clarity, it would be better to refer to the Oracle Instant Client instead of "Oracle Libs" because folks won't know what "Oracle Libs" means and you're referring to the "Oracle Instant Client").

First a note on Alpine: Alpine uses the musl C compiler (by default) instead of gcc. That's what allows it to be so small, but the trade-off is compatibility. We are unlikely to support the musl compiler and if you add gcc to Alpine, it jumps up in size to match that of other images like Buster.

Is there a reason why you can't use the Oracle Linux 7 based image with Instant Client and Node.js? Seems like the smallest, simplest option.

Indeed I was looking for as smaller as possible but, it looks like would be a smart choice going with Oracle Linux 7 Slim.

About call the Stant Client a Oracle Libs, is how I see the Oracle call it in there pages.
Screen Shot 2020-04-25 at 7 02 22 PM
https://www.oracle.com/database/technologies/faq-instant-client.html

Did I made any interpretation mistakes?

"Oracle Instant Client" is the product name and how we refer to it internally at Oracle and externally with customers and developers. Oracle also has thousands of products, so just referring to "Oracle Libs" can be confusing.

Given the tiny difference in size between the two, you're better off using the Oracle Linux based image as all the packages are tested by Oracle prior to release. Using the Instant Client on Buster via Alien is not a supported installation method.

For sure, after researching a lot on internet about it, which I think it would be more clear in Docker Hub to help out all community, I am going with Oracle Linux 7 Slim Image.

Please Oracle, would be smart given a clear instructions about this in Docker Hub.

@Djelibeybi assuming that I am going with Oracle Linux 7 Slim, what is your thoughts to try reduce its sizes? Most of the web softwares engineers came from an age that container must be tiny as possible.

That is my argue point here and also why most of the people always start from Alpine images.

Holpe I give you some tips whats is going on the wbe in general.

The oraclelinux:7-slim image is the smallest it can possibly be while still being able to add more packages. It does not need to be reduced in size and is smaller than almost all other base images, excluding Alpine.

However, as I explained above, Alpine isn't always suitable because of the difference in C libraries used by default. If you install GCC into Alpine, it's size jumps up to about the same as the Oracle Linux 7 slim image (from memory, it's around 90MB or so).

Keep in mind that your Node.js is pulling in about 40MB of additional dependencies (based on the size of your images in the original post) which is 50% as large as the entire operating system base on which it runs. Node.js is not known for creating small applications.

I'm not sure where on the Docker Hub you'd like us to make this clearer, though?

"Oracle Instant Client" is the product name and how we refer to it internally at Oracle and externally with customers and developers. Oracle also has thousands of products, so just referring to "Oracle Libs" can be confusing.

As confusing as for who is not so close to Oracle products like me kkkkk. I changed in the topic all mention about Oracle Libs

I'm not sure where on the Docker Hub you'd like us to make this clearer, though?

Here: https://hub.docker.com/_/oracle-instant-client

There is only a picture, any instruction, nothing. The checkout procedure also make everybody run away from there looking for another alternative such as Alpines or Buster.

For me, it looks like I have to pay for it, give one of my kidney to the Oracle to use it.

Right, I'd forgotten about that image. I agree that could probably be improved. I'll let the internal folks know.

Note that we have no control over the checkout system used by Docker. All our images on Docker Hub are free to use (as long as you accept the license terms, i.e. for development purposes only).

Other tip, on dock hub would be nice giving some common uses for it like Node JS. ;-)

@cjbj we should keep this in mind for any future updates to the official Oracle Instant Client image.

I did a quick test to see if I could reduce your Buster image size and if you replace all your individual RUN directives with this, it comes out a tiny bit smaller than the Oracle Linux version:

RUN apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade && apt-get install -y alien libaio1 wget && \
    wget https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/getPackage/oracle-instantclient19.3-basiclite-19.3.0.0.0-1.x86_64.rpm && \
    alien -i --scripts oracle-instantclient*.rpm && \
    rm -f oracle-instantclient19.3*.rpm && apt-get -y --purge remove alien && \
    apt-get -y autoremove && apt-get -y clean

However, it may be removing too many packages. The problem with using Alien to install an RPM on Debian is that the dependencies for the package are not maintained in the dpkg database. So, while this option may result in a smaller image (in my test, it was 297MB so 4MB smaller than the Oracle Linux image), it may not actually work properly if the Instant Client depends on a library that gets removed.

Just for your information, this clean command improved a lot the image site.

Thank you @Djelibeybi for you help. But I have no doubt that I am going with oracle linux 7 slim image :-)

Screen Shot 2020-04-25 at 20 33 58

You're welcome. I'm going to close this issue now, so if you have any further questions or problems, please open a new issue.

There we can see two docker images supported by Oracle. oraclelinux:7-slim and node:12.9.1-buster-slim.

The latter is not 'supported'. It may work, and I'm sure people are using it, but that's a different kettle of fish.

I assume that is a official Oracle instruction, ins't?

No! It's a blog post.

Good point. Hey @cjbj, can you please change your blog post to use https? :)

All my Dockerfile wgets on Docker for Oracle Database Applications in Node.js and Python were already using https. Just a couple of in-paragraph links to yum.oracle.com and linux.oracle.com weren't (they are now). I've also updated the URL in the older blog post addendum.

If you want node-oracledb instructions, don't forget the actual node-oracledb documentation: Using node-oracledb in Docker

Was this page helpful?
0 / 5 - 0 ratings

Related issues

veqryn picture veqryn  路  16Comments

xenoterracide picture xenoterracide  路  26Comments

karan-kapoor90 picture karan-kapoor90  路  32Comments

kenshaw picture kenshaw  路  15Comments

hillol-pal picture hillol-pal  路  14Comments