Development in Docker
This page describes how to develop, build and test Ambari on Docker.
In order to build Ambari, there are a quite few steps to execute and it is a bit cumbersome. You can build an environment in Docker and are good to go!
This is NOT meant for running production level Ambari in Docker (though you can run Ambari and deploy Hadoop in a single Docker container for testing purpose)
(This is not only about Jenkins slaves but think it is your laptop)
First, we will make a Docker image that has all third party libraries Ambari requires.
Second, prepare your code on Docker host machine. It can be trunk or a branch, or your developing code or with a patch applied. Note that your code does not reside inside of Docker container, but on the Docker host and we link it by Docker volume (like mount)
And you are ready to go!
This code has been migrated to Ambari trunk.
There are a few system requirements if you want to play with this document.
Create Docker Image
First thing first, we have to build an Docker image for this solution. This will setup libraries including ones from yum and maven dependencies. In my environment (Centos 6.5 VM with 8GB and 4CPUs) takes 30mins. Good news is this is one time.
This is going to build a image named "ambari/build" from configuration files under ./dev-support/docker/docker
For example our unit test Jenkins job on trunk runs on Docker. If you want to replicate the environment, read this section.
- 'docker run' is the command to run a container from a image. Which image was run? It is 'ambari/build'
- -h sets a host name in the container.
- -v is to mount your Ambari code on the host to the container's /tmp. Make sure you are at the Ambari root directory.
- ambaribuild.py runs some script to eventually run 'mvn test' for ambari.
- -b option is to rebuild the entire source tree. It runs test as is on your host if omitted.
You want to run Ambari and Hadoop to test your improvements that you have just coded on your host. Here is the way!
- --privileged is important as ambari-server accessing to /proc/??/exe
- -p 80:80 to ensure you can access to web UI from your host.
- -p 5005 is java debug port
- 'deploy' to build, install rpms and start ambari-server and ambari-agent and deploy Hadoop through blueprint.
You can take a look at https://github.com/apache/ambari/tree/trunk/dev-support/docker/docker/blueprints to see what is actually deployed.
There are a few other parameters you can play.
test: mvn test
server: install and run ambari-server
agent: install and run ambari-server and ambari-agent
deploy: install and run ambari-server and ambari-agent, and deploy a hadoop