Run Tomcat under Docker container, deploy application __docker

Source: Internet
Author: User
Tags docker cp docker run

Entry level, simple record under Docker run Tomcat, deploy your own development application, please explain the error. First, Docker installation

According to the official website of the instructions download docker.dmg mirror files, and usually install the same steps installed software can be completed.
Website address:
https://docs.docker.com/docker-for-mac/install/ Two, pull the tomcat image

To search for Tomcat image file information:

? Docker search Tomcat

Pull the corresponding mirrored file:

? Docker pull Tomcat:7

Tomcat:7 is the specified pull version and, if not specified, pulls the latest version

Start authentication Tomcat

Docker Run-p 8080:8080 Tomcat:7

-P followed by port mapping: Host host Port: Docker container Port

Enter http://ip:8080 in the browser verify that Tomcat starts successfully . Deployment Application

There are two ways to deploy applications: 1. Mount the application directory on the host host

If our application is in the directory:/users/apple/webapp directory

? Docker run--privileged=true-v/users/apple/webapp:/usr/local/tomcat/webapps/demo-p 8080:8080--name Appdemo Tomcat : 7

Where: –privileged=true is the right to grant Docker mount
/users/apple/webapp Host Host Directory
/usr/local/tomcat/webapps/demo Docker container Tomcat directory
-P Port Mappings
–name container name 2, copy applied to tomcat application directory

Start Tomcat:

Docker run-p 8080:8080--name WebApp tomcat:7

Copy applied to container application directory

? Docker CP Demo.war Webapp:/usr/local/tomcat/webapps

WebApp is the name of the container specified at startup.

To view the container directory file structure:

? Docker exec-it Webapp/bin/bash

After entering, you can see the directory structure of Tomcat in the container clearly,
WebApp is the name of the container specified at startup.

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.