简体   繁体   English

为什么这会有什么不同? 搬运工/ MySQL的/ apache2的

[英]why would this make any difference? docker/mysql/apache2

i can barley explain whats happening but check it out... i am using Docker over here with mysql, php, apache2. 我可以大麦解释发生了什么,但要检查出来...我在这里将Docker与mysql,php,apache2一起使用。

it makes a difference if i start everything up at once like this: 如果我像这样立即启动所有程序,则会有所不同:

docker-compose up mysql apache2

or if i decide to first start only mysql in a terminal window like this: 或者如果我决定首先在终端窗口中像这样仅启动mysql:

docker-compose up mysql

and in a seperate terminal window apache2: 并在单独的终端窗口apache2中:

docker-compose up apache2

if i start up all at once it happens many many times that i end up with following error: 如果我一次全部启动,它会发生很多次,并最终出现以下错误:

Missing Tablespace

sometimes it helps to just use 有时它有助于使用

docker-compose down

followed by another 其次是

docker-compose up mysql apache2

but most of the time the error is consistent. 但大多数情况下错误是一致的。 i can avoid this error all the time with starting the systems in seperate windows, first mysql - once its fired up i start apache2. 我可以始终在单独的Windows中启动系统来避免该错误,首先是mysql-一旦启动,我就会启动apache2。

how can this be a thing? 这怎么可能呢? i dont have enough docker knowledge to understand this kind of issue, but i would like to. 我没有足够的Docker知识来理解此类问题,但我想这么做。 in my opinion apache should not talk to mysql until the actual application gets hit by a request? 在我看来,在实际应用程序遇到请求之前,apache不应与mysql对话?

any advice is much appreciated - let me know if further information is needed 非常感谢任何建议-如果需要进一步的信息,请告诉我

There is option in docker-compse.yaml, called depends_on to define the requirement order to start your services: docker-compse.yaml中有一个选项,名为depends_on用于定义启动服务的需求顺序:

version: '3.4'
services:
  mysql:
    image: mysql:5.6
  apache2:
    image: httpd:alpine
    depends_on:
      - mysql

Then, you should use docker-compose up to start both. 然后,您应该使用docker-compose up来启动两者。

Reference: https://docs.docker.com/compose/compose-file/#depends_on 参考: https : //docs.docker.com/compose/compose-file/#depends_on

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM