docker use case
来源:互联网 发布:百合网数据库 编辑:程序博客网 时间:2024/05/29 16:42
http://www.wouterdanes.net/2014/04/11/continuous-integration-using-docker-maven-and-jenkins.html
Docker
Docker is a tool allows you to run multiple processes in their own containers on a machine without the overhead of virtual machines. It does give process separation and to the processes it looks like they're running in their own linux environment. Docker was created in Go and is basically an interface to Linux Containers (LXC), a feature of the linux kernel that was introduced in the 3.8 release.
Docker works well under Ubuntu and Red Hat is working to make it enterprise ready for RHEL.
Docker allows you to specify containers using Dockerfiles. These can be compared to Vagrantfiles that are used to provision virtual machines. These docker files can be composed of other docker files, creating a sort of inheritance / composition of containers.
Creating an Integration Server Using Docker
I created a sample project on Github that shows how you can run integration tests on a sample Hippo project using docker. If you have Vagrant, you can see the Jenkins server in action with a simple vagrant up
from the root of the project. Using the composition command in the Dockerfiles (FROM), I've built an oracle jdk 7 image that is used as the base of a tomcat image. I then use that tomcat image as the base for my integration environments. The Dockerfile for the integration image resides in the root of the project and is as follows:
FROM wouterd/tomcatMAINTAINER Wouter Danes "https://github.com/wouterd"ADD myhippoproject.tar.gz /tmp/app-distribution/RUN for i in $(ls /tmp/app-distribution/) ; do mkdir -p /var/lib/tomcat6/${i} && cp -f /tmp/app-distribution/${i}/* /var/lib/tomcat6/${i}/ ; done
The wouterd/tomcat image is built as follows:
FROM wouterd/oracle-jre7VOLUME ["/var/log/tomcat6"]MAINTAINER Wouter Danes "https://github.com/wouterd"RUN apt-get install -y tomcat6CMD JAVA_HOME=/usr/lib/jvm/java-7-oracle CATALINA_BASE=/var/lib/tomcat6 CATALINA_HOME=/usr/share/tomcat6 /usr/share/tomcat6/bin/catalina.sh runEXPOSE 8080
The wouterd/oracle-jre7 has some magic to install jdk 7 from oracle on a clean ubuntu VM. The code for this container and the two above is in the docker-images directory in the Github project. The wouterd/tomcat image does the following:
FROM wouterd/oracle-jre7
takes the container wouterd/oracle-jre7 (a container with Ubuntu + oracle java7 installed)VOLUME ["/var/log/tomcat6"]
tells the container to expose that path to the outside world. Docker actually "physically" places this path outside the container so that other containers can also reach it. Further down I will show why this is great. (Sneak peak: syslog deprecated?)RUN apt-get install -y tomcat6
installs tomcat6 using the ubuntu repositoryCMD [some bash]
sets the command that gets executed when this container is run, setting two environment variables and starting catalina.shEXPOSE 8080
tells docker to expose port 8080 in the container to the host system.
The docker container that gets built during the integration test simply does two things:
- Takes the wouterd/tomcat container
ADD [file] [destination]
copies the tar.gz with the distribution from the maven project to a temporary folder and extracts it if it's a tar.- The
RUN
line is a convoluted way to copy the contents of the tar over theTOMCAT_HOME
directory, for some reason simply adding the tar to theTOMCAT_HOME
folder didn't let it extract properly. It would probably work ifTOMCAT_HOME
was just empty. - It inherits the
CMD
directive from the wouterd/tomcat container, so if you "run" the integration container usingdocker run
, it will start up tomcat and start deploying the distribution.
- docker use case
- use case
- Use Case
- use case
- use case
- business use case
- Use Case编写建议
- The Use Case Model
- 为什么Use Case很重要
- Use case association
- use case 简析
- use case 简析 3
- 什么是Use Case?
- Use Case 问答
- 用例(Use case)
- USE CASE 分类
- Use Case Modelling
- Use Case学习笔记
- Ubuntu 日志文件
- myeclipse新手入门常见问题
- : java.lang.SecurityException: Unable to find app for caller android.app.ApplicationThreadProxy 解决方法
- HDU 2544 最短路 【Dijkstra算法】
- 为大家编写一个数据可视化的软件
- docker use case
- EnhanceIO SSD Caching
- NOJ1103&next_permutation()
- MFC多线程编码--用户界面线程(四)
- 字节序与大小端
- 判断是否为64位机
- 穿越麦田的小路
- LBS预案作战指挥系统应用
- 设计模式——备忘录模式