8000 Docker ENV variable not found · Issue #285 · symfony-cli/symfony-cli · GitHub
[go: up one dir, main page]

Skip to content

Docker ENV variable not found #285

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

Closed
TefDesign opened this issue Mar 3, 2023 · 7 comments
Closed

Docker ENV variable not found #285

TefDesign opened this issue Mar 3, 2023 · 7 comments

Comments

@TefDesign
Copy link
TefDesign commented Mar 3, 2023

When I start my local project, my Docker ENV variables are not found by Symfony CLI.
When I execute symfony var:export --multiline, I get the following output.

export SYMFONY_APPLICATION_DEFAULT_ROUTE_HOST=en.wamiz.wip
export SYMFONY_APPLICATION_DEFAULT_ROUTE_PATH=/
export SYMFONY_APPLICATION_DEFAULT_ROUTE_PORT=443
export SYMFONY_APPLICATION_DEFAULT_ROUTE_SCHEME=https
export SYMFONY_APPLICATION_DEFAULT_ROUTE_URL=https://en.wamiz.wip/
export SYMFONY_DEFAULT_ROUTE_HOST=en.wamiz.wip
export SYMFONY_DEFAULT_ROUTE_PATH=/
export SYMFONY_DEFAULT_ROUTE_PORT=443
export SYMFONY_DEFAULT_ROUTE_SCHEME=https
export SYMFONY_DEFAULT_ROUTE_URL=https://en.wamiz.wip/
export SYMFONY_DOCKER_ENV=
export SYMFONY_PROJECT_DEFAULT_ROUTE_HOST=en.wamiz.wip
export SYMFONY_PROJECT_DEFAULT_ROUTE_PATH=/
export SYMFONY_PROJECT_DEFAULT_ROUTE_PORT=443
export SYMFONY_PROJECT_DEFAULT_ROUTE_SCHEME=https
export SYMFONY_PROJECT_DEFAULT_ROUTE_URL=https://en.wamiz.wip/
export SYMFONY_TUNNEL=
export SYMFONY_TUNNEL_ENV=

When I inspect my docker container database :

"Labels": {
    "com.docker.compose.config-hash": "170c91fd8716421e27e512a3b8cd9d623a8d4fdff74e4b1a49b95c369d3ea625",
    "com.docker.compose.container-number": "1",
    "com.docker.compose.depends_on": "",
    "com.docker.compose.image": "sha256:bd02430bb338544d999651aa695dfe7cedffb1257e7edf7067fb1cf23be4db22",
    "com.docker.compose.oneoff": "False",
    "com.docker.compose.project": "international-website",
    "com.docker.compose.project.config_files": "/Users/default-admin/travaux/international-website/docker-compose.yaml",
    "com.docker.compose.project.environment_file": "/dev/null",
    "com.docker.compose.project.working_dir": "/Users/default-admin/travaux/international-website",
    "com.docker.compose.service": "database",
    "com.docker.compose.version": "2.15.1"
}

Versions :

  • Docker : 20.10.23, build 7155243
  • Docker compose : v2.15.1
  • Symfony CLI : version 5.5.1

image

@Kocal
Copy link
Contributor
Kocal commented Mar 20, 2023

Hey, I'm having the same issue than my colleague @TefDesign.

Like him, I'm using a MacBook M1 Pro, and I have the following app versions:

  • Symfony CLI 5.5.1
  • Capture d’écran 2023-03-20 à 10 21 06

And this is what outputs symfony var:export --multiline, which is a bit... empty:

export APP_ID=01C0GAP4XEQ8HG6MGTJ7JB9EDT
export SYMFONY_DOCKER_ENV=
export SYMFONY_TUNNEL=
export SYMFONY_TUNNEL_ENV=

Note that our others colleagues @Kern046 and @Geekimo use the same environment development (same laptop, same app versions) but don't have this issue.

Is there any hint that can help us to fix this problem? Thanks!

@Kocal
Copy link
Contributor
Kocal commented Mar 20, 2023

Well, after some debugging I've found that /var/run/docker.sock wasn't existing:
Capture d’écran 2023-03-20 à 11 36 18

My other colleagues have this file, but @TefDesign and me have not, but re-creating manually through sudo ln -s "$HOME/.docker/run/docker.sock" /var/run/docker.sock made everything works again.

Anyway, I think we can still print the No /var/run/docker.sock found when --debug, which would help people faster IMO

@tucksaun
Copy link
Member

Is it possible that we "just" need to update our usage of the Docker library so that it accounts for this?
Or is it more a problem on your setup?

@Kocal
Copy link
Contributor
Kocal commented Mar 21, 2023

Well, at my job we use Kandji to pre-configure this and upgrade apps (and Docker), but as said before some of my colleagues didn't have any problem. :/

Anyway, Docker was running fine even without the /var/run/docker.sock file, this file does not seems mandatory.

I see in https://pkg.go.dev/github.com/docker/docker/client#pkg-constants that you can configure DefaultDockerHost, so maybe we can do a double-check?

  • check for unix:///var/run/docker.sock , as now
  • if necessary, check for unix:///$HOME/.docker/run/docker.sock

@tucksaun
Copy link
Member

We already configure the library to check if there's any override of the docker host via their standard DOCKER_HOST environment variable.
Also I didn't find any check for presence of docker.sock in the home directory or in XDG_RUNTIME_DIR in moby's client code (but I only checked quickly so I might have missed one) 🤷

It looks to me your Docker daemon is running as a non root user, if that is the case, Docker configuration states you need to define the DOCKER_HOST env var: https://docs.docker.com/engine/security/rootless/#client
Would it be possible that somehow it is not properly exposed into your shell or your IDE terminal?

@Kocal
Copy link
Contributor
Kocal commented Mar 21, 2023

Hum you're right about DOCKER_HOST, well I never had the use or to configure it, I know my DOCKER_HOST was always empty and it was working fine until this monday.

Anyway, I've added export DOCKER_HOST="unix://$HOME/.docker/run/docker.sock" in my ~/.zshrc as it appears to be the cleanest solution for me, and it works perfectly.

Thanks for the advice :)

@jneidel
Copy link
jneidel commented Jun 20, 2023

In our case we were using Rancher Desktop but didn't have Administrative access set (requires reboot).

Screenshot 2023-06-20 at 13 24 36

That fixed it for us.

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

No branches or pull requests

4 participants
0