-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
How do I do a migration if my backend container won't start due to an error? #1345
-
First Check
- I added a very descriptive title here.
- I used the GitHub search to find a similar question and didn't find it.
- I searched in the documentation/README.
- I already searched in Google "How to do X" and didn't find any information.
- I already read and followed all the tutorial in the docs/README and didn't find an answer.
Commit to Help
- I commit to help with one of those options 👆
Example Code
$ docker compose exec backend bash
service "backend" is not running
Description
I have an error that was caused by some model code. I have updated the models and I want to create a new migration, but the following command fails:
docker compose exec backend bash
service "backend" is not running
Looking at the logs, it's clear this is caused by my model not having a relationship done properly.
Operating System
macOS
Operating System Details
Mac M1
Python Version
3.11.2
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions
In docker-compose.override.yml
comment out the following lines
command:
- fastapi
- run
- --reload
- "app/main.py"
and uncomment the line above
# command: sleep infinity # Infinite loop to keep container alive doing nothing
Then run docker compose watch
and in new terminal, attach to the container with docker compose exec backend bash
.
Now you can see something like
root@7f2607af31c3:/app#
You are inside the backend container and can run alembic commands
Replies: 2 comments
-
see here on how to apply migrations
Beta Was this translation helpful? Give feedback.
All reactions
-
In docker-compose.override.yml
comment out the following lines
command:
- fastapi
- run
- --reload
- "app/main.py"
and uncomment the line above
# command: sleep infinity # Infinite loop to keep container alive doing nothing
Then run docker compose watch
and in new terminal, attach to the container with docker compose exec backend bash
.
Now you can see something like
root@7f2607af31c3:/app#
You are inside the backend container and can run alembic commands
Beta Was this translation helpful? Give feedback.