Running database migrations during docker-compose build fails, but it works from command line Running database migrations during docker-compose build fails, but it works from command line docker docker

Running database migrations during docker-compose build fails, but it works from command line


While the image is being built, it's not yet running on a container and attached to the network to be able to see the other containers defined in our docker-compose.yml file.

Not only doing DB migration during the image build is a bad idea: it's not possible if the DB it depends on it is running on a different container and trying to reach it through its internal network name.

If the DB server is connected, which was already running and had a publicly reachable hostname, and the project was configured to use that server instead of one running in another container, it would work. But it would still be a bad idea.