MySQL container not building fast enough


#1

I’ve got an interesting case now. CircleCI builds are so fast now, that sometimes the connected MySQL container doesn’t build fast enough, and then things fail due to a connection refused error. Is there a way to get the MySQL container to build and connect faster? Or a more intelligent way than sleep(x) to make sure it’s ready before connecting.


#2

Dockerize or netcat are the two best options.

dockerize -wait tcp://localhost:3306 -timeout 1m
nc -z 127.0.0.1 3306

#3

Hmmm not sure if Laravel would be able to work with this. The error happens when Laravel goes to connect to the MySQL host to create and seed the database tables.


#4

You just need to have this command prior to your composer migration.


#5

Ahh got it, sorry didn’t get that. Let me update the build config and try it out


#6

No worries :slight_smile: That’s why we have support


#7

Quick update to our docker image to add those commands, and that seems to be working now. Thanks for the tip!


#8

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.