phpdockercomposer-phpdocker-compose

How to start Docker container only after another container is exited


Let's suppose I have 2 containers: composer and php, which share the same code base, i.e. the same volume. And I want to manage them with a single docker-compose command like docker-compose up.

So the question is How can I start these containers one by one, not at the same time? I mean, start my php container only after composer one is exited, i.e. composer container should install all vendors for my php container and exit, then and only then php container should start a built-in PHP web server with already installed vendors.

P.S. Now I get the behavior that both containers start at the same time. So my php container is trying to start web server without vendors, while composer container is trying to install these vendors.

Is there a good solution for this case?


Solution

  • There are couple of things can help you;