oracle / docker-images

Official source of container configurations, images, and examples for Oracle products and projects
https://developer.oracle.com/use-cases/#containers
Universal Permissive License v1.0
6.57k stars 5.43k forks source link

Produced Docker Image has very large HDD footprint #228

Closed rubenst2013 closed 7 years ago

rubenst2013 commented 7 years ago

I love this new official Docker Image for Oracle DB

Though, call me ignorant, the produced size of an empty DB Docker Image takes up about 11.1GB and pre-building an otherwise empty DB out of it amounts to a grand total of whooping 15GB! O.O Am I missing any cleanup steps here? Otherwise the sheer size of the thing hinders our efforts and definitely is any issue for us.

Thanks in advance for any assistance. :)

Edit: I used 12.1.0.2 SE2

brunoborges commented 7 years ago

Out of curiosity, what is your average VM size with only the DB installed?

clemSeveillac commented 7 years ago

@rubenst2013 note you can significantly lower the image size by "squashing" its layers, with that flow (which will become a one liner in docker 1.13 experimental mode):

  1. ./buildDockerImage.sh
  2. docker run --name tmp true
  3. docker export tmp | docker import - newSquashedRawImageName
  4. (with a very similar Dockerfile where FROM points to newSquashedRawImageName and you removed all RUN and COPY statements) docker build -t newSquashedImageName .

That's it, your latest image now weights 6 GB!

rubenst2013 commented 7 years ago

@brunoborges : Our average, empty DB/VM size (VMware) is right around what @clemSeveillac said: 6GB

@clemSeveillac : Thanks for the info, I will give that a go ASAP and keep you guys posted of my progress :+1:

rubenst2013 commented 7 years ago

it worked, the image actually got quite a bit smaller! YAY :D

REPOSITORY TAG IMAGE ID CREATED SIZE
oracle/db-squashed 12.1.0.2-se2 6aceb22776be 6 seconds ago 9.80 GB
oracle/db-prebuilt 12.1.0.2-se2 4c44e5f0d638 17 hours ago 15.16 GB
oracle/database 12.1.0.2-se2 83bb12215fad 17 hours ago 11.14 GB
oraclelinux latest 4c357c6e421e 6 days ago 225 MB

Though ~10 GB is still a bit heavy for an empty DB I think... I poked around inside the container:

[root@c0d45fecdcdf oracle]# pwd
/opt/oracle
[root@c0d45fecdcdf oracle]# du -h --max-depth=1
460K    ./admin
6.6M    ./diag
**5.2G  ./product**
**3.8G  ./oradata**
18M ./fast_recovery_area
4.0K    ./audit
18M ./cfgtoollogs
4.0K    ./checkpoints
1.2M    ./oraInventory
8.9G    .

Things I will try next is the special docker squash tool https://github.com/jwilder/docker-squash and I will setup a box with Docker 1.13 which has a --squash build flag.

Also I'm not quite sure what @clemSeveillac means by "docker run --name tmp true". Simply as a means to "create" a container from the image is my best guess.

(I've got still loads of things to learn about Docker and Linux in general :) )

Thanks for your help so far and I hope we can find ways to make this awesome container a bit easier to lift.

brunoborges commented 7 years ago

Alright, glad things worked out! :+1:

clemSeveillac commented 7 years ago

Same here, glad we helped you save some space! @rubenst2013 while oradata is exactly taking the space you want (tablespaces etc.), I agree product is annoyingly big...

-> Folks, if you find way to remove unneeded things from product, I'm all ears -- besides the obvious /opt/oracle/product/12.1.0.2/dbhome_1/sqldeveloper which you probably don't need in your container and which takes 167 MB.

And yeah, running true was the way I found back then to create the simplest container from an image in order to reimport it as one layer :)

brunoborges commented 7 years ago

Hey @gvenzl... Based on @clemSeveillac's suggestion of removing sqldeveloper folder, what do you think of a shrinkInstallation.sh script that removes that, and other (useless in a container) things?

rubenst2013 commented 7 years ago

I think a special shrink script, one for post-installation and perhaps one for housekeeping would be awesome! Edit: Also, what about moving things like sqlplus to a data-only container or the likes, which can be linked in when needed.