Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How do I do a migration if my backend container won't start due to an error? #1345

Discussion options

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

You must be logged in to vote

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

Docs: https://github.com/fastapi/full-stack-fastapi-template/blob/master/backend/README.md#docker-compose-override

Replies: 2 comments

Comment options

see here on how to apply migrations

#324 (comment)

You must be logged in to vote
0 replies
Comment options

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

Docs: https://github.com/fastapi/full-stack-fastapi-template/blob/master/backend/README.md#docker-compose-override

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested

AltStyle によって変換されたページ (->オリジナル) /