J
J
Julia Kovalenko2017-06-08 17:20:51
MySQL
Julia Kovalenko, 2017-06-08 17:20:51

Deploy yii2 with Docker?

I am trying to deploy a yii2 project using Docker.
I have containers running on the same network.
How and when are migrations triggered?
If I try to run them when building a container with yii2,
RUN /www/yii migrate --interactive=0
I get an error:

Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known'

in /www/vendor/yiisoft/yii2/db/Connection.php:568

Because the network has not yet been created during the build and the container with mysql has not yet been launched.
I tried writing instead of RUN ENTRYPOINT.
But the entrypoint is executed when the container is already running.
Other containers see that everything is running and try to access the database, which has just started to fill up => errors.
How to implement it?
Install in container with Mysql php, run migrations and demolish php?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
planc, 2017-06-08
@kovalenko_jul_s

https://docs.docker.com/compose/startup-order/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question