Description
1. Permission is root, not the first elevation of authority : Install Docker
1.https://docs.docker.com/engine/installation/binaries/
Download Docker latest version of the binary tar.gz
Under Linux:
wget https://get.docker.com/builds/Darwin/x86_64/docker-1.11.0.tgz
2. Thrown into the $path
MV Docker/usr/local/sbin
3. Start
Docker Daemon &
two. Run Tomcat on the container
Docker official Mirror Warehouse because there is a wall, so the download is very slow. At the moment I am using a mirror image of the speed cloud.
The first step: Pull the mirror to the local
Docker Pull Index.tenxcloud.com/tenxcloud/tomcat
Step two: Add an alias to the mirror
Docker tag Index.tenxcloud.com/tenxcloud/tomcat tomcat-1
Step two: Start tomcat
Docker run-p 5000:8080--name container1 tomcat-1
As a result, Tomcat starts, and-p 5,000:8,080 means to insinuate the container Tomcat's 8080 port to the host port so that extranet access 5000 can access our Container1 's 8080 tomcat.
As a result, a simple tomcat ran.
Here the container container1 and mirror tomcat-1, my understanding is that mirroring is a template, Container1 is a real basin created from this template, which runs on our tomcat. So we can create a lot of container with the same image. Three. Deploy our applications on Tomcat
Next we are going to deploy our application, the idea is to enter into the container1 inside, at this time can think of Container1 as a new machine, we only need to go to Tomcat WebApp lost war, and then restart on the line. 1. Go inside the container
Docker exec-it Container2/bin/bash 2. View the Tomcat WebApp path
/tomcat/webapps 3. Preach War
Throw the war on the host, throw it into the container and drop it in Tomcat/webapps.
Docker CP Demoone.war Container2:tomcat/webapps
Too TM Surprise, Docker itself on the support ah ... 666666. 4. Restart Container
No need ... Docker automatically helped you deploy.
5. Access to Applications
At this point, a complete Docker deployment of Tomcat and online a Java Web application process has gone through.
To tell the truth, it is so simple to find out after the pass. Before the concept of the above understanding of the place is also basic.
I have to say nice, exactly as expected, just use the container that Dokcer created for you as a new Linux. deploy a set of application systems using Docker
Next, deploy a complete set of systems, including the following components:
Load balancing: Haproxy
Java Worker: Tomcat
Caching: Redis Master, Slave
The process is Java opens a restful interface, writes a data for Redis,
Open a RESTful interface and read a data from the Redis.
System structure as shown:
Steps:
1. Prepare Java Project and pack it into war
2. Pull Haproxy Mirror, and run
Note--name cannot be placed at the end, 6,555:80 80 cannot be changed, is the port of Haproxy itself
Docker run-d-P 6555:80--link container2:container2 Haproxy-1 Haproxy
As you can see, Haproxy has successfully implemented the functions of the agent.
The current mirror does not know why it cannot be supported by modifying the Haproxy.cfg method, and subsequent research
Then the process of Golang mirroring and application deployment will be completed.