In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to set container dependencies in docker. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
How do I set container dependencies with docker? A slightly more complex project must not be solved by a single program, but must be a combination of many programs as a whole, and there is a certain dependency between them. For example: nginx depends on web application server tomcat,tomcat applications rely on mysql database and zookeeper configuration, applications in tomcat may depend on each other, etc.
If you manually start multiple applications, you must wait for the dependent service to be ready before starting the next application / service; but if you want the server to start automatically, you have to rely on the script to check whether the dependent service is ready or not. then start the applications / services in sequence.
Docker container deployment (deploy each application to a separate container)
When the docker container is started by service orchestration (docker-compose), the dependent container can be configured by = = depends_on==, and the current container will not be started until the dependent container is started.
But the hidden problem is that after the container starts, the application in the container may not be ready, and there will be a time interval. In order to solve this problem, we must judge whether the specific application is started or not.
Judge by dockerize tool
Use dockerize to solve service dependency issues:
The configuration in the command of each docker-compose.yaml service is as follows:
Command: ["dockerize", "- wait", "tcp://zookeeper:2181", "- wait", "tcp://mysql:3306", "- wait", "http://apphost:8080","-timeout "," 1800s "," / usr/bin/supervisord "]
Option description:
-wait
-wait parameters can be added to represent dependencies on multiple services
-timeout 1800s
-the number of seconds to wait after timeout. Default is 10 seconds.
The last command is the command to be executed after each dependent service is ready, that is, the command started by the current application.
Supported protocols are: file, tcp, tcp4, tcp6, http, https and unix
So much for sharing about how to set container dependencies in docker. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.