Let’s say the components we need are: nginx tomcat webapp redis
Our operating system is debain
Nginx is a container
Tomcat webapp is a container
Redis a container
Then integrate these containers to complete the deployment.
The question is how to access between ports. Where are the database files? Can files be shared between containers?
I haven’t used Docker before. I don’t know if my thoughts are correct. Please help me
1. You can use docker as a virtual machine, so at least there will be no learning cost. It is nothing more than to write some operating steps in the virtual machine into a dockerfile so that Docker can automatically configure it and be clearer and clearer. However, some operation and configuration steps may be difficult to implement under normal installation, and it is necessary 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 in the container from the local file system by VOLUME.
2. Use docker to build microservices, that is, internal services that are divided into different containers to form a large service. In this case, access between ports can be specified through the –link parameter when run to specify a container; The database file is specified to be mounted into the container from a local directory by-v (-volume); Sharing between container files can be done by specifying a folder as VOLUME, which is essentially to mount the directory of the local file system into multiple containers.
3. If you really want to use microservices, you need to know about docker-compose to help you manage various components. You just need to write the run configuration of the container in the yml file.