Using Docker to build a Java project development environment

Source: Internet
Author: User

first, the demand

An Ubuntu 16.0.4 LTS, with the Docker service installed, the rancher service, and the Tomcat-related image, let's take a look at how to quickly build a development environment and test environment

Second, step2.1: Create a local mount directory

Create two directories on host host hosts, a war to mount the formal environment, a war to mount the test environment, as shown in

Command: mkdir formal test

Next, create one of the simplest dynamic Web Project with Eclipse, with only one index.jsp then packaged as Testsite.war, and put Testsite.war in formal and test respectively.

directory, as shown in the

2.2: Start container

Start the test environment container Tomcat_test

50080:8080 tomcat:test1

Parameter resolution:

--name=tomcat_test: is a custom name for the container to differentiate the business from the test environment

-V: Specify the mounted local directory for the test Container/ylkj/test the package that is tested later is published to this directory of the host host/tomcat/webapps is the Tomcat's running environment directory, Specifically, it depends on how dockerfile specifies the Tomcat and Java environment

Launch of the formal environment container Tomcat_formal

:8080 tomcat:test1

Parameter resolution:

--name=tomcat_formal: is a custom name for the container to differentiate the business from the formal environment

-V: Specifies the mount local directory for the official container for/ylkj/formal after the formal package is published to this directory of the host host/tomcat/webapps is the Tomcat's running environment directory, Specifically, it depends on how dockerfile specifies the Tomcat and Java environment

As shown, you can see that the container started successfully

Go to the rancher platform to see the container of our newly created test environment and formal environment, as shown in

2.3: Access Test

The browser input http://192.168.1.53:50080/TestSite/and http://192.168.1.53/TestSite/can be seen to access our index.jsp

2.4: Modify the project folder name to root

This is the purpose of the Tomcat configuration file specified by the default access to the project is root, so that the above address can not enter the project name, direct access to IP or Ip:port can access the Web project

Enter the host's/ylkj/formal to modify the folder operation, as shown in the test environment similarly to/ylkj/test under the renaming of Testsite

The update operation is completed as shown in

Direct input http://192.168.1.53:50080 and http://192.168.1.53 are tested as follows,

In a later operation, just put the test war package into the/ylkj/test formal war package and put it in/ylkj/formal, and the Tomcat environment uses an image

The simple is that the publishing environment is the same, so there will be no test environment can run, to the formal environment will not run the situation

Using Docker to build a Java project development environment

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.