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.