I can barely explain what's happening but check it out... I am using Docker over here with MySQL, PHP, and 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:
docker-compose up mysql
and in a separate terminal window 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 separate windows, first mysql - once its fired up I start apache2.
How can this be a thing? I don't have enough docker knowledge to understand this kind of issue, but I would like to. In my opinion apache should not talk to MySQL until the actual application gets hit by a request?
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:
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.
Reference: https://docs.docker.com/compose/compose-file/#depends_on