Docker image with multiple layers

I am planning to dockerize my application server, what is the best way to install the several components?

current environment: Linux host, Weblogic 11, Java 7, Oracle Client 10g(no database server), sshd etc

plan for building Docker Image :

  1. create base image from Centos
  2. start a container from step 1
  3. Install Weblogic 11 using rpm/yum
    4.commit and save an image version
  4. start a container from step 4
  5. Install java 7 with rpm/yum
  6. commit and save an image version
    . . and so on for other software required and create a final BASE image

is this the correct approach? In future if i need to update a specific software like upgrading to Java 8 (which is one of the middle layer of my BASE image) will i be able to just update the specific layer? or do i need to build the image allo over again?
or Are there any other great ideas for dockerizing the applications?



The plan you have listed not the right approach for dockerizing your application. You should learn to write Dockerfile. The commit and save strategy is not reusable and extendable. The example of upgrading JAVA itself is a great example of why this approach is bad.

If you are following the Dockerfile approach you can get all the steps done in the dockerfile, and you can build the docker image out of the Dockerfile. And any change to your stack is just a change in the Dockerfile and a rebuild.

So to conclude it looks like this.

Dockerfile >> Docker Build >> Docker Image >> Run Docker Container

And all the future updates is just an update in the Dockerfile.


Please let me know if you need more clarification.