In the past, application deployment meant moving lots of components – provided by developers to lots of servers, databases etc. managed by Operation. With Docker and containers, we often hear statements like: “That all goes away now – developers simply have to deliver a ready-to-go Docker image, and we’re done! No more need for app deployment tools like XL Deploy!”
Having worked with many users moving towards container based deployments, it turns out that that statement simply isn’t true: while Docker and containers can certainly make some aspect of packaging and deployment easier, many challenges remain that tools like XL Deploy can help with.
The packaging of an traditional application depends how it has been written: operating system (Linux, Windows), language (Java, C#, Ruby Python, JS..), its behaviors (Frontend, Backend, Web, Processing), using or not database (SQL, NoSql)… It is also true with the associated environment and its infrastructure: Host (Virtual, Cloud), the operating system (Linux, Windows), the middleware (Tomcat, Apache Httpd, IIS, IBM WebSphere, ..), the data (MySQL, MongoDB).
In XL Deploy, we would have the following classic deployment where
- The PetPortal version 2.0-89 contains: petclinic (jee.War), petclinic-backedn (jee.War), petDatasource (jee.Datasource), sql (sql.SqlFolder), logger (a custom type to configure log4j.properties)
- The Tomcat-Dev environment contains: tomcat-dev (tomcat.Server), tomcat.vh (tomcat.VirtualHost), sql-dev (sql.MySqlClient), smoke-test (smoketest.Runner).
Traditional Deployment Application
The Docker’s promise is the following: “one single kind of item in the package (docker.Image) will be deployed on a single kind of target (docker.Machine) to become a running Docker container.”
What are the modifications If I package and deploy my PetPortal application using Docker ?
- in the package, instead of having 2 jee.War file (petclinic, petclinic-backend), I would have 2 docker.Image based on a tomcat:8.0 from the Docker Hub and that contains the war file and its configuration but I would keep my ‘smoke test’ and my ‘sql’ folder. Moreover, I would need to package the property file externally to my image (a image is like a commit, do not modify it ! )
- in the environment, I would replace the ‘tomcat.Server’ and the ‘tomcat.VirtualHost’ by a single ‘docker-machine’ only and I would keep my ‘sql-dev’ MySql SQL client, test-runner-1 (smoketest.Runner).
Finally few things has changed but the deployment task generated by XL Deploy is a bit different to use the ‘docker’ commands:
- No more ‘war copy’ steps but ‘docker pull’ steps
- No more ‘start tomcat process’ steps but ‘docker run’ steps
Dockerized Application with XL Deploy
If we detail into the docker run 2 commands generated by XL Deploy and its xld-docker-plugin:
- for the ‘petclinic-backend’ container, the command is simple as we can read in any docker blog post or documentation:
docker run -d --name petclinic-backend petportal/petclinic-backend:1.1-20150909055821
- for the ‘petclinic’ container, the command is a bit complex because we need to configure it – according to the documentation the ‘docker run’ command may accept up to 56 parameters, many of them can be added several times. In our simple case: we need
- to link it with the petclinic-backend,
- to manage exposed ports,
- to mount volumes to apply the configuration,
- to set environment variables:
- so the generated command is:
docker run -d -p 8888:8080 --link=petclinic-backend:petclinic-backend -v /home/docker/volumes/petportal:/application/properties -e "loglevel=DEBUG" --name petclinic petportal/petclinic:3.1-20150909055821
As the ‘petclinic’ container needs to be linked to the ‘petclinic-backend’, the xld-docker-plugin takes care to generate the steps in the right order to run first the linked container and then the other container.
Like the other middleware, the main pain point is not to call remote commands but to generate the right commands with the right configuration in the right order.
Two mains direction comes immediately:
- the container configuration with its more than 50 parameters including the network, os, security settings: TCP port mapping, links with other containers, Memory, Privileges,….cf docker run documentation
- the volume management, for example: The container configuration is often done by providing a set of files that need to be first uploaded to docker-machine and then mount the volume in the container; Same story when you run the container that manages data (e.g : SQL database)
In the following scenario, the configuration is managed by the ‘config’ docker.Folder that contains placeholders in .properties files. When a value is modified, the folder should be uploaded and the container restarted.
Dependency Management with XL Deploy
So it can be difficult to manage the configuration for a given environment, but the application still needs to be deployed on several environment. XL Deploy’s dictionaries help you. Moreover, moving to Docker imply most of time moving to Microservices architecture that will imply more deployments. See the XL Deploy Docker Microservice Sample Application.
This article originally appeared at the Xebia Labs blog by Benoit Moussaud.