Why I prefer a Docker image instead of VM or OVF image



I think lxc/cgroups/Docker will be the standard for application packaging,
I see lxc/Docker container what I saw 16 years ago in servlet specification
several months later the community started to talk about the J2EE.
I like the container image because it is basically a TAR file, is it easy to manipulate, lots of tools such as 7zip, WinZip can read and update a TAR format.
A container image only contains the linux packages that your application
needs to run properly, depending on the container image the size is around 400 MB.
In the last two years I was packaging application servers and web servers in
VM image or OVF format, the image size is around 10 GB or even more, it was
really hard to manipulate this kind of image size, hard to do minor changes, in some
cases OVF format images are hard to migrate from one hypervisor to another (different vendor)
lxc/Docker seems to be linux distribution independent, hypervisor independent.
Now I'm  going to show you how easy is to do a simple change in docker image, in this example I have to change the Tomcat http listener port to 8090.

I start this tutorial from a container exported image

1) To export an existing container

    docker export 9e45b0a21e79 > /tmp/nginx_java.tar

2) Extract the tomcat's server.xml

    tar -xvf nginx_java.tar  "./opt/apache-tomcat-7.0.47/conf/server.xml"

3) Change the listener port

    vi ./opt/apache-tomcat-7.0.47/conf/server.xml

4) Update the tar file with the just updated server.xml

    tar -uvf nginx_java.tar  "./opt/apache-tomcat-7.0.47/conf/server.xml"

5) Import the new docker image

    cat nginx_java.tar | docker import - nginx_java_tomcat:v2.0

6) Run the new docker image.   
    docker run -p 8090:8090 -i -t nginx_java_tomcat:v2.0 /bin/bash 

Comentarios

Entradas populares