- Install Docker, this example uses CentOS 7, other systems installed please Baidu.
- Installation: Yum-y Install Docker
- Start: Service Docker start
- Some basic Docker commands are:
- Docker images
- Docker pull
- Docker PS
- Docker images xxxx
- Docker stop xxxx
- ......
- Installing Mysql:docker Pull mysql:5.6
- Run Mysql:docker run-d-P 3306:3306-e mysql_root_password=root mysql:5.6
Command explanation:
-e mysql_root_password=root means to change the root user's initialization password to root
-D indicates background run
-P 3,306:3,306 indicates port mappings for containers and virtual machines
- Installing Tomcat7:docker Pull Tomcat:7
- Upload a web app to the virtual machine/usr/local directory, here/usr/local/t, which reads the database and then uploads the data back to the browser for presentation.
- Start Tomcat in the Docker container
Command explanation:
-v/usr/local/t:/usr/local/tomcat/webapps/t to mount the T file in the/usr/local/directory of the virtual machine to the/usr/local/tomcat/webapps/directory
-D indicates background run
-P 5,217:8,080 indicates port mappings for containers and virtual machines
--privileged=true to grant Docker mount permissions
- In the host input Http://ip:5217/T access the project:
Run a javaweb application in Docker