C
C#16mo ago
Pedro Furlan

✅ Docker Compose don't execute images in order

Hey everyone ! I've create a docker compose for my personal project , and i wanna run in order of image. In my example , i have an docker image who was created by dockerfile, and after this , an image of Sql Server. In my dockerfile personal project , i clean and build the project to verify if it's ok to proceed , then , i run the command : WORKDIR /src/Portifolio.Infrastructure.Database RUN dotnet ef database update -v -s ../Portifolio.WebApi in this point , it was suppose the sql image be already created to run this command , but , independent of the order i put in compose file , he ignores me , and run always first my docker build (dockerfile). Follow my docker compose and my dockerfile in attachment to analisys.
3 Replies
jcotton42
jcotton4216mo ago
That's not how docker works The images are completely built before they're started in any way, via compose or otherwise
jcotton42
jcotton4216mo ago
I would suggest migrating on app startup, like I do here https://github.com/jcotton42/spear/blob/main/src/Spear/Program.cs#L116
GitHub
spear/Program.cs at main · jcotton42/spear
Contribute to jcotton42/spear development by creating an account on GitHub.
Pedro  Furlan
Pedro Furlan16mo ago
I understand, it's weird not being able to define an order on docker compose , the order who each image will run. But i'll try do for your way. Thanks for your help and attention.