1, download the image
docker pull tomcat:7-jre7
2, create a map catalog
mkdir -p /data/tomcat/webapps /data/tomcat/logs
3, create a container -p indicates the address mapping
docker run -di --name=tomcat-pro -p 9000:8080 -v /data/tomcat/webapps:/usr/local/tomcat/webapps -v /data/tomcat/logs/:/usr/local/tomcat/logs tomcat:7-jre7
Parameter analysis:
Docker run: Create a container
-d: run behind the -d parameter will create a guard vessel in the background (this will not automatically logged container after container is created, if only two plus -i -t parameters, after you create will automatically go in the container).
-i: Run indicates a container
-p: mapping the port, the former is a host port, which is mapped in the port of the container. You can use multiple -p do more port mapping
-v: representing the directory mapping relationship (the former is the host directory, which is mapped to a directory on the host), you can use multiple -v do multiple directories or file mappings . Note: It is the directory for mapping, making changes on the host, and then to share the container.
tomcat: 7-jre7: image name used
- View the container has up
docker ps
access
We also found not visit, because the current position, webapps below actually works yet, are not a basis, we cp a ROOT to the next / data / tomcat / webapps / directory can
ROOT files can be decompressed under linux version I copied
Well, before you can refresh the page access
Get!
Let us look at the directory logs folder under it, no problem mapping
Here, if we want to map a different directory, you can use your own
docker exec -it container ID / bin / bash command into the container, look at your own directory structure, you can map their own
For example, the mapping server.xml tomcat