Docker deployment Tomcat and Web application __docker

Source: Internet
Author: User
Tags docker ps docker cp docker run
First, online download Docker
Yum install-y epel-release

yum install docker-io   # Install Docker chkconfig on     # join Boot

Service Docker start     # launch Docker service
Second, Docker install Tomcat container 2.1. Find the server's Tomcat information

2.2 Download down the official mirror starts the tallest one

Docker Pull  Docker.io/tomcat    
2.3 View all mirrors of Docker
Docker images     

2.4 Start Tomcat

Docker run-p 8081:8080 docker.io/tomcat    #  If the port is occupied, you can specify the container and host mapping port The former is the perimeter access port: The latter is the container internal port

2.5 access to 192.168.138.132:8080 after startup

third, deploy your own web references

Docker PS     # Use the following command to view a running container

3.1. Upload your own war package to the mainframe

3.2. Execute view address in container ComCat

Docker  exec-it   3cb492a27475   /bin/bash    

3.3 threw the war bag into the host , threw it into the container and dropped it into Tomcat/webapps.

Docker CP Nginxdemo.war 3cb492a27475:/usr/local/tomcat/webapps
3.4. Start Tomcat or reboot docker restart "container ID"
Docker Run-p 8081:8080 Docker.io/tomcat
3.5 View has started mirroring
Docker PS

3.6 Performing View items in the container comcat

Docker  exec-it   3cb492a27475   /bin/bash    #中间那个是容器id (container_id) 

Cd/webapps

ls   # You can find our project.
3.7 The above implementation has a disadvantage is that the container restart after the project will be no longer, the following is the mode of 2 boot in the form of Mount
Docker run-d-v/usr/docker_file/nginxdemo.war:/usr/local/tomcat/webapps/nginxdemo.war-p 8080:8080 Docker.io/tomcat  
3.8 The first two ways to use in the test environment, after all, to constantly modify the code, Mode 3 can be put into production use. is also the way the official website suggests

VI Dockerfile

From Docker.io/tomcat:latest    #你的 Tomcat mirroring
maintainer XXX@qq.com    #作者
COPY nginxdemo.war   /usr/ Local/tomcat/webapps  #放置到tomcat的webapps目录下

3.8.1 to generate a new mirror:

Docker build-t Nginx-demo:v1.  

3.8.2 start a new mirror

Docker Run-p 8080:8080 Nginx-demo:v1

other

# Basic Information View Docker

version # View Docker versions, including client, server, dependent go Docker Info  
# View System (Docker) level information, including managed images, Containers number, etc.

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.