-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Support setting DOCKER_HOST in .env file #9210
Comments
I can confirm that setting DOCKER_HOST in an .env file does not work anymore with docker compose v2. Steps to reproduce: docker-compose.yml:
.env:
Only when I set
I used bogus host and context values for demonstration purposes. The same holds true for correct values. Output of
Output of
|
I have experienced the same issue as prullmann after following their procedure. The Output of
Output of
|
related to #9345 |
@hskingr Can you please elaborate what works for you and what not? |
Any updates on this? Had to use compose V1 as a result to read DOCKER_HOST from .env file. |
@trcoelho Does that work well for you? When I run However, I struggled to create a small example to reproduce this behaviour. |
- DOCKER_HOST
- DOCKER_CONTEXT Both do not work as environment variables in docker compose v2 They both work when docker compose is set to v1 in the docker desktop preferences with the command
|
A few days ago commit #9512 was merged that could also fix this issue. |
Hi @prullmann . Have checked and still docker compose V2 does not read DOCKER_HOST environment variable as V1 does.
Client: Server:
Thank you. |
I can confirm that neither Steps to reproduce:Make sure Plain compose command: Setting Defining Using Setting Defining Using docker infoClient: Server: |
It seems #9512 by @ulyssessouza implemented feature request #9345 not by loading the default |
Hello @prullmann , as we can confirm that is really happening, do we have any scheduled date as a result to solve that? Thank you. |
Hi @trcoelho, I am just a user trying to help getting this fixed. |
Also can confirm that this has burned/caught me off guard a few times. I forgot a few months ago, got a new laptop and its happening again. I use DOCKER_HOST to remotely manage multiple local compose servers and not have configs on the server. This appears to not be possible unless you toggle (enable compose v2) in the docker desktop settings. An update would be awesome to get this resolved. I'm wondering if I there would be a different way to change the docker daemon to point to a remote host. |
Hello, have updated to the latest Docker Desktop version 4.10.0 and this issue was not resolved.
Client: Server:
Docker version 20.10.17, build 100c701 Thank you. |
@requiem240sx There is DOCKER_CONTEXT, but that also doesn't work with compose v2 and is non-existent in v1. |
Hello, do we have any news regarding this one? Have updated to the latest docker version:
And it still docker compose V2 does not read DOCKER_HOST .env variable. @ulyssessouza , has any thoughts? Thank you. |
What happened here is that the variable was correctly loaded but not applied into docker A fix is on its way -> #9745 |
Thanks @ulyssessouza ! |
Hi @ulyssessouza , when this will be available? Thank you! |
Upon further review, we’ve decided to not support dynamically setting Compose v2 is a Docker CLI plugin, and we want to ensure consistent behavior across all CLI plugins, which means using the "inherited" Docker API connection provided to the plugin, respecting all options, such as the active context. If you were relying on this functionality, I’d recommend taking a look at projects such as direnv, which can automatically set environment variables such as |
Well, don't get it because we have that behavior on docker compose V1, which helps a lot when we have to manipulate several environments remotely. Believe keep using V1 then :). Thanks for the updates. |
@milas Thanks for clarifying, sounds sensible so far. You say that compose should not define the connection depending on its own configuration (eg
Is that the way to go or are there more clever ways? |
Hi @milas , as per docker documentation this environment variable should work on docker compose V2: https://docs.docker.com/compose/environment-variables/envvars/ Is this correct? If DOCKER_HOST is unavailable for compose V2, what should be the correct way to deploy in different servers? Thanks in advance. |
I know this was closed a while ago, but i would just like to chime in and say that this feature would have been really appreciated. |
Description
With Compose V1 we have the ability to set a project-specific
DOCKER_HOST
in .env, with V2 this is no longer possible.Steps to reproduce the issue:
.env
file with a custom value forDOCKER_HOST
docker compose
commands target the default docker hostDescribe the results you received:
docker compose
commands target the default docker hostDescribe the results you expected:
docker compose
commands target the docker host specified in .envOutput of
docker compose version
:Output of
docker info
:Additional environment details:
N/A
The text was updated successfully, but these errors were encountered: