Docker-from installation to deployment of a Web application (go, Java) __web

Source: Internet
Author: User
Tags redis java web docker cp docker run haproxy

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.