使用Docker部署java web应用
阿神
阿神 2017-04-24 09:12:08
0
4
563

假设我们我需要的组件有:nginx tomcat webapp redis

我们的操作系统是debain

nginx是一个容器
tomcat webapp是一个容器
redis一个容器
....
然后把这些容器整合,完成部署

疑惑的是端口之间如何访问?数据库文件在哪?各容器之间文件是否可以共享?

没有使用过Docker 不知道思想是否正确,求各位大侠解惑

阿神
阿神

闭关修行中......

reply all(4)
左手右手慢动作

1. You can use docker as a virtual machine, so at least there will be no learning cost in using it. It is nothing more than writing some operating steps in the virtual machine into a Dockerfile so that Docker can automatically configure it, making it clearer and clearer. However, some operations and configuration steps may be difficult to implement under normal installation. You need to learn from other people's writing methods on docker hub.
In this way, access and file sharing between ports are not a problem; database files can be placed in the container, or mounted from the local file system to the container through VOLUME.
2. Use docker to build microservices, which means dividing it into different containers to form the internal services of a large service. In this case, access between ports can be specified by specifying the --link parameter when running to specify a container; the database file can be mounted from a local directory to the container by specifying -v (--volume); the container file Sharing between containers can be done by specifying a folder as VOLUME. In essence, it is just mounting the directories of the local file system to multiple containers.
3. If you really want to use microservices, you need to understand the docker-compose technology to help you manage various components. You only need to write the run configuration of the container in the yml file.

迷茫

Mine is mysql tomcat fastdfs
mysql uses -p to map the 3306 port
tomcat 8080 fastdfs has been changed to 8081
The host ip is 10.0.15.4
So the configuration in the tomcat project is to connect 10.0.15.4 / 3306 / 8081
That’s it, Then iptables opens the dokcer container network segment to access the host

If you have nginx, just forward it directly to 8080 of tomcat in nginx

阿神

docker-compose, docker service orchestration.

刘奇

If all the components you use serve an application, it is recommended to use Docker orchestration tools, such as the officially provided Compose.
Files and data between containers can be shared, which can be achieved by mounting data volumes;
The most convenient way to connect between containers is to connect through the link parameter, which will establish a dedicated channel between the two containers and avoid exposing the data port to the outside world. Security risks caused by opening up.
If you want to do it, it is recommended that you familiarize yourself with the most basic things first, it is quite interesting.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!