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
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.
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.