Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker compose up not working #534

Open
DungBuiDeveloper opened this issue Aug 23, 2023 · 18 comments
Open

docker compose up not working #534

DungBuiDeveloper opened this issue Aug 23, 2023 · 18 comments

Comments

@DungBuiDeveloper
Copy link

  • so many error when init project pleease check
@bibektimilsina000
Copy link

https://github.com/bibektimilsina000/FastAPI-PgStarterKit
here is the working project if you only want backend part of this project

@Happily-Coding
Copy link

Happily-Coding commented Apr 24, 2024

Just a heads up, I download this project recently and it worked for me without any modifications.

@menkotoglou
Copy link

Hey @DungBuiDeveloper, I recently used the project and seems really smooth. I guess you need to explain what issues you face in the issue, so that we have a guide to help you with it.

@emirakdere
Copy link

emirakdere commented Aug 10, 2024

I also could not just make it work out of the box. When I run docker compose up I get errors like the following

proxy-1 | 2024-08-10T00:27:21Z ERR github.com/traefik/traefik/v3/pkg/server/router/router.go:136 > error="middleware "full-stack-fastapi-project-www-redirect@docker" does not exist" entryPointName=https routerName=full-stack-fastapi-project-frontend-https@docker

proxy-1 | 2024-08-10T00:27:21Z ERR github.com/traefik/traefik/v3/cmd/traefik/traefik.go:355 > Router uses a non-existent certificate resolver certificateResolver=le routerName=full-stack-fastapi-project-adminer-https@docker

EDIT: these errors still persist, but a docker compose up --build creates a fresh build and works out of the box!

@freegoatw
Copy link

I have the same issue as you @emirakdere, sadly a simple docker compose up --build does not fix anything.

@kulimantang
Copy link

Same Problem here, already spent hours trying to figure out how to acces front & backend when I run Docker Compose - everything starts up, but they do not appear on localhost or localhost/api or localhost/docs as they should.

@johe123qwe
Copy link

I have the same issue

@kulimantang
Copy link

The issue for me was not the template but my own system, I had Rancher Desktop running, which has its own instance of traefik running within the local kubernetes cluster. I switched off the kubernetes cluster and it worked out of the Box :)

@unoriginalscreenname
Copy link

I had it working out of the box, and I was really excited. But after I tried to add a new table and did an alembic migration i am now getting the same error as you! I have no idea what is going on. Does anybody have an idea how to fix this or even what is happening? I tried rolling things back but still no good.

@unoriginalscreenname
Copy link

I don't know what happened, but I managed to get rid of the error. Then I tried another database migration and now i'm back to the traefik errors again. This is really frustrating.

@AtticusZeller
Copy link

  • so many error when init project pleease check

did you guys follow the instruction,it may help

@unoriginalscreenname
Copy link

For now i'm developing locally. it was working just fine, but something happened when I tried to create a new database table that caused a catastrophic meltdown for my project. This error basically locked me out and i don't know why or how to reset. In the process I accidentally deleted my last alembic version before i finished downgrading to it. so, it's all a huge mess. two things that would really help me out:

  1. is there an easy way to just completely reset the database and then bring it back up to the last version file?
  2. is there a way to auto generate a table and all the associated crud on the back end? Some php or ruby frameworks have a cli tool that does all that for you. right now i have to touch about 6 files and I can't keep track of it all.

Any help here would be awesome. I struggle with all of this docker and dev ops stuff.

@unoriginalscreenname
Copy link

I managed to get the server running again somehow this morning and began making progress again. However, I changed something in the docker configuration to add an additional host, and the entire thing fell apart. It won't build, the backend won't run, and i can't track down the issue.

This framework looked really promising, but I have to say that the back-end with docker is brutal. I have no idea how to get it started back up again. I've reverted everything back, I've tried to upgrade the database head, i've deleted the docker containers and volumes, i've tried to do a --build. This framework works really well until it just doesn't. If anybody has any tips on this, docker is not my strong suit. I'm working in the development environment on windows 11. i'm running the backend in docker and then i'm running npm build dev so I can work locally.

2024-08-31 10:11:37 proxy-1 | 2024-08-31T15:11:37Z DBG github.com/traefik/traefik/v3/pkg/middlewares/recovery/recovery.go:22 > Creating middleware entryPointName=https middlewareName=traefik-internal-recovery middlewareType=Recovery
2024-08-31 10:11:37 proxy-1 | 2024-08-31T15:11:37Z DBG github.com/traefik/traefik/v3/pkg/server/router/tcp/manager.go:237 > Adding route for adminer.localhost with TLS options default entryPointName=https
2024-08-31 10:11:37 proxy-1 | 2024-08-31T15:11:37Z DBG github.com/traefik/traefik/v3/pkg/server/router/tcp/manager.go:237 > Adding route for localhost with TLS options default entryPointName=https
2024-08-31 10:11:37 proxy-1 | 2024-08-31T15:11:37Z DBG github.com/traefik/traefik/v3/pkg/server/router/tcp/manager.go:237 > Adding route for www.localhost with TLS options default entryPointName=https
2024-08-31 10:11:37 proxy-1 | 2024-08-31T15:11:37Z ERR github.com/traefik/traefik/v3/cmd/traefik/traefik.go:355 > Router uses a non-existent certificate resolver certificateResolver=le routerName=full-stack-fastapi-project-adminer-https@docker
2024-08-31 10:11:37 proxy-1 | 2024-08-31T15:11:37Z ERR github.com/traefik/traefik/v3/cmd/traefik/traefik.go:355 > Router uses a non-existent certificate resolver certificateResolver=le routerName=full-stack-fastapi-project-backend-https@docker

@unoriginalscreenname
Copy link

I can't even get a fresh install from the repository working now. I have no idea.

  1. clone repository
  2. copy the .env file to the backend directory
  3. npm install in the front end directory
  4. poetry install in the backend directory
  5. docker compose up -d

what am i missing here. I'm completely shut out in a local dev environment. Has anybody else experienced this?

@MP242
Copy link

MP242 commented Sep 5, 2024

same issue for me!

@MP242
Copy link

MP242 commented Sep 6, 2024

Good evening everyone,

After facing this error, which suddenly appeared without clear explanation, I decided to start from scratch. Below is my approach:

First, I recommend watching Tiangolo’s video, which explains how to set up Traefik with a FastAPI server and its own Docker image: "FROM tiangolo/uvicorn-gunicorn-fastapi.10."

https://www.youtube.com/watch?v=7N5O62FjGDc

Next, while looking at my proxy logs more closely, the first warning/error I noticed was that it couldn't find the network "traefik-public." In the production config, you need to first run docker network create traefik-public and then use it as external: true. In the development config, it was set up with external: false, but strangely, it wasn't working anymore.

Finally, I switched the network to driver: bridge in the docker-compose.yml file.

networks:
  traefik-public:
    driver: bridge

Then I realized that while using this template, I had changed the stack name and forgot to update the "STACK_NAME" environment variable. I eventually removed the STACK_NAME from the docker-compose.yml and added a container_name for each service.

adminer:
    container_name: adminer
    image: adminer
    restart:...

OLD: - traefik.http.routers.${STACK_NAME?Variable not set}-adminer-http.rule=Host('adminer.${DOMAIN?Variable not set}')

NEW: - traefik.http.routers.adminer-http.rule=Host('adminer.${DOMAIN?Variable not set}')

After that, I noticed that the lines - traefik.constraint-label=traefik-public were incorrect. By running docker inspect backend, I found that the network name used by my containers was "my-project_traefik-public", where "my-project" is the folder name where I used this template. So, I replaced all the constraint-labels with my actual network name.

There you go, enjoy debugging! Stay strong everyone!

@martin-prillard
Copy link

It works! Thanks @MP242

@nlfox
Copy link

nlfox commented Nov 18, 2024

Given this issue is a bit confusing, I'm going to share how I debugged through this issue.

Lesson learnt: non-existent certificate resolver is masking real issue that prevent docker compose to start up.

After the docker compose up exited, I found docker ps shows some container (db, frontend) already running.
And docker compose exited when trying to run prestart. And console shows proxy-1 | 2024-08-10T00:27:21Z ERR github.com/traefik/traefik/v3/cmd/traefik/traefik.go:355 > Router uses a non-existent certificate resolver certificateResolver=le routerName=full-stack-fastapi-project-adminer-https@docker

I tried to manually start prestart by docker compose up prestart, and found that it actually failed due to my password is less than 8 letters. Update my password to 8+ characters solved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests