Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Pit case Analysis of Docker deployment Service

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains the "pit case analysis of Docker deployment service". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "pit case analysis of Docker deployment service".

This project uses spring cloud+spring boot+spring gateway+mysql and rabbitmq. The server is centos7.

I replaced the zuul with gateway. Zuul is based on servlet 2.5 (using 3.x) and uses blocking api. It does not support any persistent connections, such as websockets. Gateway, on the other hand, is based on spring framework 5 project reactor and spring boot 2, using non-blocking api. Websockets is supported, and because of its tight integration with spring, it will be a better development experience.

The docker image service uses Aliyun's container image service. I asked my colleague and said that I used google's container tool jib. So cmd+shift+f searched jib all over the world.

Click in to see

Go to Aliyun to find the container image service (omit here the steps of not knowing that the image warehouse is partitioned, and thinking that you have no permission if you cannot find the warehouse, and then brazenly asking for the administrator account to modify the employee account of the former colleague and still can't find the warehouse)

Then I created a namespace xxx-prod and built a warehouse for each service in that space. Private warehouse. The code source I chose is the local warehouse to push to the image warehouse. I don't know much about the rest.

(later, it is found that there is no need to build. Jib submission will automatically create the repository and select it when creating it manually.) after you submit it using jib, you can see the update in the version information of the repository.

Then connect to the server. Create a docker folder under the home folder

/ / in the root root directory / / ~] # centos7 emmm how to put it, that is, above gitbash and os systems is $windows under cmd is > / / home create a docker folder ~] # mkdir / home/docker// enter the created docker~] # cd / home/docker

Then start pull and upload to the image of Aliyun. In fact, any directory can be pull (when I omitted the first pull Ali image service here, I didn't read the operation guide. I once suspected that my account didn't have permission, but I didn't have login all the time, but I didn't realize that I should add Aliyun's image address: registry.cn-hangzhou.aliyuncs.com.) in Aliyun's image service management console, click on an image warehouse-- > manage. You can see the operation guide for the image warehouse.

Enter after the image is pulled.

~] # docker images

You can see the mirror image you just got to by pull.

I asked my colleague why there were so many images here, and he explained to me

Emmm, all right! Always feel that there are a lot of images taking up memory (I hope the boss who knows it will not hesitate to give us your advice, thank you)

Start eureka

~] # docker run-d-- name eureka-p 8761pur8761-p 15672etc/localtime:/etc/localtime registry.cn-hangzhou.aliyuncs.com/xx_xxx_prod/eureka// 15672-p 9001etc/localtime:/etc/localtime registry.cn-hangzhou.aliyuncs.com/xx_xxx_prod/eureka//-d background run-p bind port here three ports are bound, one is the port of the registry itself, one is the port of the gateway, and the other is the port / /-v print version information of rabbitmq

Because rabbitmq is used, you also need to create another rabbitmq container. Or pull the mirror image first.

/ / Note: get the management version when you get the image, but not the last version. Only the management version has the management interface. ~] # docker pull rabbitmq:management~] # docker run-d-- name rabbit-e rabbitmq_default_user=xxx-e rabbitmq_default_pass=xxx-- network=container:eureka rabbitmq:management// because the docker containers are separated by the network-- network is added to the same network environment as eureka so that it can be accessed by services under eureka governance. / /-e is to set the default account password instruction is xxx. Friends who use it, please adjust it yourself.

Then start your own service.

~] # docker run-d-- name xxx-v / home/docker/web-prod/logs:/logs-v / etc/localtime:/etc/localtime-- network=container:eureka registry.cn-hangzhou.aliyuncs.com/xx_xxx_prod/xxx / /-v mounts the log to the directory you set. Similarly-- network joins eureka's network, where there is no need to bind ports. / / after startup, you can view the service status in the registry console. The port of ip + eureka.

In this way, the service will run. Other service steps are similar. Finally, add some small episodes encountered in the online. At first, I didn't know that the network between docker containers was cut off, and I couldn't connect to rabbitmq, because I didn't use network if eureka's network. Therefore, the localhost in the service cannot access the rabbitmq. Also, if the rabbitmq delay queue is useful in the service, you also need to install a plug-in for the delay queue. Plug-in installation steps

Open the official website to download: http://www.rabbitmq.com/community-plugins.html select the corresponding version "3.7.x" and click to download. ~] # docker cp / home/docker/rabbitmq_delayed_message_exchange-20171201-3.7.x.ez rabbit:/plugins// goes inside docker ~] # docker exec-it rabbit / bin/bash// Open plug-in rabbitmq-plugins enable rabbitmq_delayed_message_exchange// to view all installed plug-ins rabbitmq-plugins list

Installation succeeded, as shown in the figure:

When docker rm deletes the container, it suddenly cannot be deleted. Docker ps-a found that the status of the container was dead, and looked up a lot of information on the Internet, such as forcibly deleting, checking mount status, manually deleting folders, and checking port occupancy. Almost all of them have been tried, but to no avail.

In the end, probably as a result of experience, I turned off both nginx and httpd and then I could delete them. Don't ask me why I installed both nginx and httpd on the same server. This project was originally a php project, deployed by them, and I took over the nginx I used myself.

There is also a very strange problem, although solved, but later I still do not quite understand why this is the case. There is a last_password_reset_date in the user table. When the user logs in, the time field is checked and the token is reported to be invalid. After entering the log of each field, the time difference of this field is 10 hours different from that in the database. At that time, I thought it was a time zone problem. But the time of another register_date field in the same table is normal, so the time zone is not processed. I checked for a long time and thought that the time type accepted by java was wrong, or that my colleague had processed this field. It's never been done. Later, I put the online environment face test library and found that it was normal again. Finally, I take a look at the time zone of the test environment database, which is the East eighth District. Online libraries are the default gtm. Finally, it would be nice to change the time of the formal library to the East eighth District.

Another is redis, because there was an official account service that used redis. At that time, the redis service was on the host. Therefore, I want to connect to the server host, but I can't connect it at first. Later, I changed the configuration file of redis and bound the bind parameter to the private network ip. Then the program uses the intranet ip to connect to the redis.

Thank you for your reading. The above is the content of "pit case analysis of Docker deployment service". After the study of this article, I believe you have a deeper understanding of the pit case analysis of Docker deployment service, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report