CLI Not respecting .env file when using Docker
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start by tracing how the Symfony CLI loads project .env values for symfony serve and symfony console, then compare behavior with Docker running and stopped using the reproduction steps and debug:container --env-vars. The issue reports conflicting environment values but names no source files or tests, so first locate the relevant environment-loading code and tests. Done means the project’s DATABASE_URL is used consistently while Docker is running.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I have local project that I'm setting up that uses docker for DB.
I've updated .env for DATABASE_URL env var to reflect what db url is but after serving that project with symfony serve errors appear Unknown database 'root'
After digging a bit in what's happening, it appears that symfony CLI is not using .env file from the project as it should, but it rather appears that it's using some other .env file when my docker is up.
Steps to reproduce:
- install default symfony app
- use docker for DB with provided yaml file
docker-compose.yaml
version: '3.7'
services:
database:
image: 'mariadb'
environment:
MYSQL_ROOT_PASSWORD: password
ports:
- '3306:3306'
- start docker
docker-compose up -d - update your
.envfile to use DB that you want (in my case it'sDATABASE_URL="mysql://root:[email protected]:3306/symfony?serverVersion=mariadb-11.2.2" - run command to create DB
php bin/console doctrine:schema:createand your dbsymfonyshould be created - (optional) if you run
symfony console doctrine:schema:createyou'll see message that dbrootwas created
Findings:
Now where does this error comes from as my db name is symfony and not root.
After checking symfony console debug:container --env-vars I've got this result:
DATABASE_URL "mysql://root:[email protected]:3306/root?sslmode=disable&charset=utf8mb4&serverVersion=1:11.2.2+maria~ubu2204" which means Symfony CLI didn't actually use my local .env file but rather something else.
Then it came to my mind to check what will happen if I stop docker DB, and re-run previous command. Response was different and I got what was actually in my defined DATABASE_URL: DATABASE_URL "mysql://root:[email protected]:3306/symfony?serverVersion=mariadb-11.2.2"
What should be expected behaviour?
Symfony CLI should use projects defined .env file
Symfony CLI Version:
Symfony CLI version 5.8.7 (c) 2021-2024 Fabien Potencier (2024-02-08T11:42:34Z - stable)
This issue could be related to #425 and #152
- Ngôn ngữ chính
- Go
- Star
- 608
- Fork
- 140
- Merge trung bình
- 2 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của symfony-cli/symfony-cli
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
symfony-cli/symfony-cli#788 ·
-
Local server fails to start when $HOME is a symlinkCó thể đã có người làm @RyoKusnadi đã nhận hôm nay. Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 72/100
symfony-cli/symfony-cli#787 · 1 bình luận · 1 reaction ·
-
Do no tail the logs option not honouredCó thể đã có người làm @fabpot đã nhận 12 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 1/100
symfony-cli/symfony-cli#784 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
symfony-cli/symfony-cli#741 · 1 reaction ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
symfony-cli/symfony-cli#739 · 1 bình luận ·
Tất cả issue của symfony-cli/symfony-cli
Issue tương tự
-
agent-butler-finding bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
jordansmall/spindrift#6414 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Icinga/icinga-kubernetes#294 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Cluster details: the Control Plane version field has a different border color than its icon boxĐang mởkind/design sig/ui
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
kubermatic/dashboard#8449 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
filecoin-project/curio#1632 ·
Maintainer thường phản hồi trong vòng 1 ngày