In the traditional model, the development team completes the software development in the development environment, does the unit test itself, passes the test, ᨀ to the Code version Management library. Operation of the application deployment to the test environment, QA testing, no problem, notify the deployment of the release to the production environment. The above process involves at least three environments: development, testing, and production. The reality is that the development of self-test no problem, but to the test or production environment program can not run, let the development team to troubleshoot, after a long time to find the final test environment is a third-party library obsolete. Such a phenomenon is common in software development and does not apply to today's rapid development and deployment. Docker can meet your needs.
Aliyun Container Hub Developer platform, where you can download the required mirrors
Https://dev.aliyun.com/search.html?spm=5176.1972343.0.1.MSG1P3
First look at the kernel version, this step is important
View System kernel version, docker requirements kernel version is more than 3.10, recommended (do not install the use of the centos6.6 above Docker, there are many pits, I just stepped over the)
I am using the Aliyun ECS CentOS 6.6 64 bit, so I need to upgrade the kernel version of the upgrade method:
# rpm--import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# RPM-UVH http://www.elrepo.org/ elrepo-release-6-6.el6.elrepo.noarch.rpm
# yum--enablerepo=elrepo-kernel install kernel-lt-y
# vim/etc/ grub.conf
default=0 changed default=1 to default = 0
Finally reboot the server
Start Installation Docker
# Curl-ssl https://get.docker.com/| SH
# Docker--version
Docker version 1.7.1, build 786b29d
# vim/etc/sysconfig/docker
other_args= " Registry-mirror=https://rr8hxwoy.mirror.aliyuncs.com-h tcp://0.0.0.0:235-h unix:///var/run/docker.sock "Configure Aliyun acceleration Docker pull will be soon.
Start Docker
#/etc/init.d/docker Start
# chkconfig Docker on
Running the Docker container
# Docker pull CentOS latest:pulling from CentOS 3690474eb5b4:already exists af0819ed1fac:already exists<
C11/>05fe84bf6d3f:already exists
97cad5e16cb6:already exists
digest:sha256 : 934ff980b04db1b7484595bac0c8e6f838e1917ad3a38f904ece64f70bbca040 Status:image is up to
date for centos:latest
From the Aliyun private mirrored warehouse pull CentOS mirrored to the local, because the Aliyun image acceleration is configured, so the download is very fast, 30 seconds to fix.
# Docker Images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos latest 97cad5e16cb6 days ago 196.5 MB
# Docker run-d-it centos/bin/bash run CentOS container
# docker ps-a CONTAINER
ID IMAGE COMMAND CREATED STATUS PORTS NAME S
969ad48e4085 CentOS "/bin/bash" 5 seconds ago up 4 seconds jovial_torvalds
# docker exec-it 969a/bin/bash Enter container 969A is the ID of the container
Docker start container command in the front has been discussed in detail, no children's shoes can go to my previous blog to see
Here's the point.
Application of Java+tomcat in containers
Test environment Server Configuration CentOS 6.6 64-bit, 4-core processor, 8G memory
Theoretically can run 16 Java containers, because each container consumes about 500M of memory, I ran 8 Java containers on top, and ran a nginx to do the reverse agent and a redis,nginx and Redis are not used Docker
Need to download good jdk1.7.0.72 and Tomcat and put them in the same level directory as Dockerfile
Vim Dockerfile #This is my i-
dockerfile
#version 1.0
#Base image from
centos:latest
# Maintainer hh Wang
#ADD
add jdk1.7.0_72.gz/usr/local/
add biz-tomcat.tar.gz/usr/local/
#RUN
Run yum-y install wget gcc gcc-c++ make OpenSSL openssl-devel vim
RUN net-tools
#EN V
env java_home/usr/local/jdk1.7.0_72
env jre_home $JAVA _home/jre
env CLASSPATH.: $JAVA _home/lib:$ Jre_home/lib
env PATH $PATH: $JAVA _home/bin
env catalina_home/usr/local/biz-tomcat
expose 8080
CMD ["/usr/local/biz-tomcat/bin/catalina.sh", "Run"]
# docker build-t Whh/biz_tomcat:v1. There's a point behind that must be remembered
Docker run-it-d-v/mnt/docker/myapp/root/biz:/docker/myapp/root-v/var/log/biz-tomcat/logs:/usr/local/biz-tomcat/ Logs-p 9080:8080--name Biz Whh/biz_tomcat:v1
Tomcat's root directory to be modified in advance for its own path, I here for docker/myapp/root, the root directory hanging in the host's/mnt/docker/myapp/root/biz directory, when the code update, the code directly to the directory, Then restart the container, no need to upload the code to the container, which is troublesome.
[Root@vm_159_91_centos biz]# ps-a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 969ad48e4085
cento S "/bin/bash" minutes ago minutes jovial_torvalds
F67257661e70 Registry "/entrypoint.sh/etc 7 hours ago up 7 Hours 0.0.0.0:5000->5000/tcp high_darwin
4bcc381f5b9f whh/biz_tomcat:v1 "/usr/local/biz-tomc 9 hours ago up 7 hou RS 0.0.0.0:9080->8080/tcp Biz
# docker tag whh/biz_tomcat:v1 ip:5000/whh/biz_tomcat:v1 IP write their own local intranet IP or public network IP can be
# Docker push IP:5000/WHH/BIZ_TOMCAT:V1 push to its own private warehouse, from other servers can be directly pull down to use
00:19:15 2016-11-16
The above is a small set to introduce the Docker 7 Docker in the Aliyun of the use of detailed, I hope to help you, if you have any questions welcome to my message, small series will promptly reply to everyone, here also thank you for your support cloud Habitat community site!