https://pantsbuild.org/ logo
#general
Title
# general
n

narrow-vegetable-37489

11/30/2021, 2:12 PM
Hmm. Having some issues with
./pants publish
and
DOCKER_HOST
in our CI environment.
./pants package
is connecting to the custom daemon address specified in
DOCKER_HOST
just fine, but when running
./pants publish
I get "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?".
Copy code
$ echo $DOCKER_HOST
<tcp://dockerdaemon:2375/>

$ ./pants publish ::
04:59:07.04 [INFO] Starting: Building docker image <redacted>:latest.
04:59:18.63 [INFO] Completed: Building docker image <redacted>:latest.
04:59:18.64 [INFO] Built docker image: <redacted>:latest
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
๐„‚ <redacted>:latest failed.
Unsetting
DOCKER_HOST
, or changing it to something invalid, makes the "Cannot connect to..." error show up even before building. So it seems like it's ignoring the value set in
DOCKER_HOST
for the part where it pushes to the registry.
m

modern-wolf-36228

11/30/2021, 2:17 PM
Copy code
[docker]
env_vars = ["DOCKER_HOST"]
on
pants.toml
, I guess?
h

hundreds-father-404

11/30/2021, 2:17 PM
If that fixes it, we should almost certainly add DOCKER_HOST to the default for that option
๐Ÿ™Œ 1
m

modern-wolf-36228

11/30/2021, 2:18 PM
it fixed for me 3h ago ๐Ÿ˜Ž
โค๏ธ 1
h

hundreds-father-404

11/30/2021, 2:23 PM
Sweet! @modern-wolf-36228 any interest in submitting a PR? You would simply add default=["DOCKER_HOST"] to the relevant option in docker_options.py
n

narrow-vegetable-37489

11/30/2021, 2:24 PM
Already have it in my pants.toml sadly, still happens ๐Ÿ˜ž
Copy code
[docker]
env_vars = [
    "DOCKER_HOST",
]
h

hundreds-father-404

11/30/2021, 2:24 PM
Note that we should only have it be in the default, we should not hardcode that DOCKER_HOST is always autopopulated. It's important users can override what the value is set to
n

narrow-vegetable-37489

11/30/2021, 2:25 PM
If I remove
env_vars
from
pants.toml
then
./pants package
starts failing too. With
env_vars
only
./pants publish
fails and only after building the image (when pushing to the registry I assume).
h

hundreds-father-404

11/30/2021, 2:28 PM
Hm it looks like the env vars are being set: https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/docker/goals/publish.py You could run with -ldebug to see the argv and env vars that are being used to publish. Or --no-process-execution-local-cleanup and inspect the __run.sh script
n

narrow-vegetable-37489

11/30/2021, 2:30 PM
Will do!
Seems like I'm running a version of Pants (2.8.1rc0) where this fix isn't available: https://github.com/pantsbuild/pants/pull/13669
๐Ÿ‘ 1
h

hundreds-father-404

11/30/2021, 2:59 PM
Good find! Sounds like we should cherry-pick that PR
โœ… 1
โž• 1
c

curved-television-6568

11/30/2021, 3:05 PM
It does have the
needs-cherrypick
label on itโ€ฆ ๐Ÿ˜‰ but apart from that, Iโ€™d forgot about it already..
๐Ÿ˜† 1
w

witty-crayon-22786

11/30/2021, 5:47 PM
@curved-television-6568: if you wouldnโ€™t mind doing the cherry-pick, iโ€™d be happy to do the release
c

curved-television-6568

11/30/2021, 5:48 PM
Sure thing. I'll do it later tonight. Thanks :)
w

witty-crayon-22786

11/30/2021, 7:57 PM
๐Ÿšข
iโ€™ll try to get another 2.8.x prepped in my tonight
๐Ÿ‘ 1
๐Ÿ™Œ 1
5 Views