In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
In this article Xiaobian introduces in detail "how to run MyEclipse in Dockerfile to build JavaWeb project", the content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to run MyEclipse to build JavaWeb project in Dockerfile" can help you solve your doubts.
The principle for an application to run in a docker container is the same as that on a physical machine, so our steps for deploying this javaweb project to docker should be as follows:
Server support (choose centos7 here)
Install the java environment
Install the tomcat environment
Delete all files (folders) in the webapps/root directory under the tomcat root directory
Copy all the files (folders) in the webroot directory of the web project developed by yourself to the webapps/root of tomcat
Start the tomcat service
The steps are clear, but you need one more thing to make a docker image: dockerfile.
Dockerfile is a file that contains special instructions that docker can recognize. After you have created the dockerfile file, you can use docker build to create the docker image.
Start building a docker image
Create a folder webapp for this example
Copy the webroot of the project to this folder
Create a dockerfile file
The structure is as follows:
Build docker image structure diagram
Create a mirror
Docker build-t "zsl131/web01".
Note:
Docker build: creating a docker mirror
-t "zsl131/web01": specify the image name. Here, the zsl131/web01; image name is composed of the repository and the name. Zsl131 is the warehouse name for which I applied for registration with hub.docker.com, and web01 is the image name.
Notice that there is a space in front of it, which means to find the dockerfile file in the current directory to build the image.
The following example creates the dockerfile of the docker image. To better understand dockerfile, you can delete all the instructions in the following file, and then execute each additional line: docker build-t "zsl131/web01". So you can see all kinds of information when using dockerfile to build the image:
# from centos:7# based on centos7 can enable the following command when you don't know how to install jdk, and then run it directly: docker build#run yum search java | grep jdk# selects the appropriate version of jdk to install run yum install-y java-1.7.0-openjdk.x86_64# to create a directory called web under the root directory run mkdir / web/# to set the working directory to / web After setting up, you can use: run pwd to view the current path workdir / web/# install wget to facilitate download tomcatrun yum install-y wget# download tomcat compressed file run wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-6/v6.0.48/bin/apache-tomcat-6.0.48.tar.gz# extract tomcat file run tar zxvf apache-tomcat-6.0.48.tar.gz# setup tool Directory workdir / web/apache-tomcat-6.0.48/webapps/root/# to view all files (folders) in the current directory At this time, there will be some files included in tomcat run ls-l# delete all files in the current directory (folder) run rm-rf * # delete and then list, there is no file run ls-l# copy all files (folders) in the webroot directory to the current directory namely (webapps/root) You can also use the copy instruction add webroot. # after the replication is completed, you can list whether the run ls-l # has been successfully copied and set the working directory to the bin directory of tomcat, so that the tomcat service workdir / web/apache-tomcat-6.0.48/bin/# exposes port 8080 expose 808 of tomcat to start the tomcat service, so that the startup will not be overwritten by entrypoint during docker run [". / catalina.sh", "run"]
After the dockerfile is written, finally, use the following command to build the image:
Docker build-t "zsl131/web01".
You can view the image you just built by using the command docker images.
Run the container
Docker run-d-- name web01-p 8014 zsl131/web01
Description:
Docker run: run the container command
-d: running in the background
-- name web01: set the container name to web01
-p 80displacement 8080: specify the exposed port as 80, that is, when external access to port 80 will map to port 8080 in the container
Zsl131/web01: image name
View the container startup log
Docker logs web01
Description:
Docker logs: view Container Log command
Web01: the name of the container being viewed. This is web01.
Visit
Open the browser and enter: http://192.168.99.100 to access the javaweb project created by myeclipse.
Note: 192.168.99.100 is the ip address of my docker host, which can be viewed through docker-machine inspect test01, where test01 is the name of the docker host.
After reading this, the article "how to run MyEclipse to build a JavaWeb project in Dockerfile" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it. If you want to know more about the article, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.