DanWahlin / AspNetCorePostgreSQLDockerApp

ASP.NET Core with PostgreSQL Docker App Demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle migrations when composing.

dcruz1990 opened this issue · comments

How can i apply migrations inside a Docker Container? So when the container start creates all tables on database.

If you want to manually run the commands you can shell into a container using "docker exec" and then run commands from the command-line. More details on "docker exec" can be found here:

https://docs.docker.com/engine/reference/commandline/exec/

If you want to automate that then your Dockerfile would need to have commands included in it that are run as the container is created (they would have to account for making sure the DB is up and available of course). This example doesn't handle that specific scenario and I don't have an example of that, but I would assume someone has probably blogged about that type of scenario. Hope that points you in the right direction.