-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
-
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
# First part of the .env file at project root
# Domain
# This would be set to the production domain with an env var on deployment
# DOMAIN=localhost
DOMAIN=alang-my.tailscale.machine.ts.net
# Environment: local, staging, production
ENVIRONMENT=local
PROJECT_NAME="My Project Name"
STACK_NAME=my-stack-name
# Backend
# BACKEND_CORS_ORIGINS="http://localhost,http://localhost:5173,https://localhost,https://localhost:5173,http://localhost.tiangolo.com"
BACKEND_CORS_ORIGINS="http://my.tailscale.machine.ts.net,http://my.tailscale.machine.ts.net:5173,https://my.tailscale.machine.ts.net,https://my.tailscale.machine.ts.net:5173,http://my.tailscale.machine.ts.net"
Description
I followed the backend/development.md to change the domain. But even after doing
docker compose up -d
or
docker compose down
# Them manually deleting all related images, then
docker compose up -d
I can see that traefik is still trying to only serve on localhost. Accessing my custom domain returns a 404
Curiously, on the traefik dashboard, only the backend has the updated STACK_NAME applied to my backend, and all the rest still retained the project default stack name:
But no matter, as you can see, it is still trying to serve on localhost despite the fact that my env file changed to use a different domain.
Am I missing some configurations? Can someone help?
Thanks!
Operating System
Windows
Operating System Details
Docker version 26.0.0, build 2ae903e
Python Version
Python 3.12.2
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions
@yohaoquan I might have the answer for you. There seems some misconfiguration within the docker-compose.yml
file. Currently it is defined as:
env_file:
- .env
environment:
- DOMAIN=${DOMAIN}
By priority it takes DOMAIN from your host env variables first and overwrites the one in the .env when you run docker compose up
.
Try to execute echo $DOMAIN
on your host environment and see whats coming there.
Actually, I am not sure why both are defined in the docker-compose.yml
file.
You can remove the following line and it should work fine:
- DOMAIN=${DOMAIN}
@tiangolo why do you declare the environment
and the .env
file in docker-compose.yml
?
Replies: 1 comment 4 replies
-
@yohaoquan I might have the answer for you. There seems some misconfiguration within the docker-compose.yml
file. Currently it is defined as:
env_file:
- .env
environment:
- DOMAIN=${DOMAIN}
By priority it takes DOMAIN from your host env variables first and overwrites the one in the .env when you run docker compose up
.
Try to execute echo $DOMAIN
on your host environment and see whats coming there.
Actually, I am not sure why both are defined in the docker-compose.yml
file.
You can remove the following line and it should work fine:
- DOMAIN=${DOMAIN}
@tiangolo why do you declare the environment
and the .env
file in docker-compose.yml
?
Beta Was this translation helpful? Give feedback.
All reactions
-
Hey @willhama I appreciate you answer, there are lots of .env
declarations in the docker-compose.yml should we remove all of them?
Beta Was this translation helpful? Give feedback.
All reactions
-
Hey @niyazikemer I personally prefer to have the env variables all in the .env
file. DevOps can be tedious and a concisely written .env
file is much easier to manage. In your docker-compose.yml
you define both. So I would suggest removing all env variables from the environment
section in the docker-compose.yml
file unless its a variable that is actively passed to the shell (e.g. timestamps or build-stamps) or you need them during your CICD steps.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Ahh sorry for the misunderstanding. I was not the owner of the original question. Basically I am having a similar problem. I've deployed my app without any error it looks it is working. But the site seems dead from the outside world. I believe there is a problem with the traefik. I'll try then maybe I can create a discussion for my specific case. Thanks for your help.
Beta Was this translation helpful? Give feedback.
All reactions
-
@niyazikemer be sure you open your ports to the outside on the server. 443 and 80. As well define the env variables correctly so the SSL certificate can be loaded correctly.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 2