Docker actual combat (deployment project)

First add the knowledge of installing mysql in docker:

One: Install mysql in docker

1.docker pull mysql:5.6

2. Run the image and generate the container: Database user name: root root password: 123456 The port when the database is connected is 12345

 3. Data backup:

 At this point, the installation of mysql in docker is complete, it is very convenient to download with docker, and the steps are relatively few, just two steps:

1). docker pull xxx;

2).docker run -it /-d ......;

To enter the container 4. mysql in , may be used MySQL mysql -uroot -p view information, and a server exactly the same operation, the premise is already running mysql vessel, and into the container ;

Two: Step into the topic: Deploy the project in docker

Before deploying the project, I had many questions, do I need to install jdk in docker? , Tomcat?, nginx?

I tried it step by step. Before, I installed the jdk image in docker, but I didn't run the container to open it, and I successfully ran to access the project.

In other words, I only installed mysql in docker.

1. I use the dockerFile configured in idea, and then associate it with the server:

After the configuration, the docker cannot be connected in the idea, see the error message in the above figure:

Explain that docker needs to enable the remote connection function. In CentOS, add the following configuration to the docker startup parameters to open the remote connection.

Docker startup parameter modification path: the default is /lib/systemd/system/docker.service

Reference: https://tsov.net/uupee/22800/    Use systemd to control and configure Docker

Reference: https://www.cnblogs.com/Purgeyao/p/11407532.html

But I did not succeed according to the above operation. I showed the modification status of my own docker configuration file and docker.service:

2. At this step, idea can be successfully bound with docker, and then run dockerFile in idea, which is build, generate project image, and then run in server to generate corresponding container, and you are done. , I first used the background startup of docker run -d -p xxxx:xxxx, and the project could not be accessed externally. I accidentally used the interactive startup of docker run -it -p xxxx:xxxx, and the external access was successful. I haven't figured out the situation now. The big guy who knows the reason, please point it out, my brother is grateful! ! !

 

 

Guess you like

Origin blog.csdn.net/zhangleiyes123/article/details/107635244