gentle-painting-24549
05/03/2023, 5:23 PMdocker_environment
) to build the PEX and subsequent docker_image
target.
Everything works great locally until it came time to publish our docker_image
from CI/CD (GitHub Actions self-hosted runners). The build fails with the following error when I specify a docker_environment
on the pex_binary
target:
Exception: Failed to obtain version from local Docker: error trying to connect: No such file or directory (os error 2)
As best as I can tell the DOCKER_HOST
environment variable isn’t getting passed down into the build process and it’s not finding the docker binary when trying to run docker -v
. I’ve specified DOCKER_HOST
and a number of other vars in the docker.env_vars
table and have also tried supplying them to the docker_environment
target itself.
I’ve seen a few somewhat-related issues around this in the slack history, and so I’m wondering if there’s an issue with my pants config or if docker_environment
just isn’t ready for primetime. (I’m on pants 2.15.0, but have tried other versions too)witty-crayon-22786
05/03/2023, 5:35 PM2.15.1rc2
fixes this.witty-crayon-22786
05/03/2023, 5:36 PMgentle-painting-24549
05/03/2023, 5:41 PMgentle-painting-24549
05/03/2023, 6:14 PM2.15.1rc2
yesterday and still ran into that error. I’m also not seeing any mention of DOCKER_HOST
in the debug logs either.
18:12:17.69 [ERROR] 1 Exception encountered:
Engine traceback:
in select
..
in pants.core.goals.publish.run_publish
`publish` goal
in pants.core.goals.publish.package_for_publish
..
in pants.core.goals.package.environment_aware_package
..
in pants.backend.docker.goals.package_image.build_docker_image
..
in pants.backend.docker.util_rules.docker_build_context.create_docker_build_context
..
in pants.core.goals.package.environment_aware_package
..
in pants.backend.python.goals.package_pex_binary.package_pex_binary
..
in pants.backend.python.util_rules.pex.create_pex
..
in pants.backend.python.util_rules.pex_from_targets.create_pex_from_targets
..
in pants.backend.python.util_rules.python_sources.prepare_python_sources
..
in pants.core.util_rules.source_files.determine_source_files
Get all relevant source files - environment:docker_x86
in pants.engine.internals.graph.hydrate_sources
Hydrate the `sources` field - (environment:docker_x86, packages/moz-service-proto/moz_service_proto/central_point.proto:../proto)
in pants.backend.codegen.protobuf.python.rules.generate_python_from_protobuf
Generate Python from Protobuf - environment:docker_x86
in pants.backend.python.util_rules.pex_environment.find_pex_python
Prepare environment for running PEXes - environment:docker_x86
in pants.core.util_rules.subprocess_environment.get_subprocess_environment
..
in pants.engine.internals.platform_rules.environment_vars_subset
..
in pants.engine.internals.platform_rules.complete_environment_vars
..
in pants.engine.process.fallible_to_exec_result_or_raise
..
in pants.core.util_rules.environments.extract_process_config_from_environment
..
Traceback (no traceback):
<pants native internals>
Exception: Failed to obtain version from local Docker: error trying to connect: No such file or directory (os error 2)
witty-crayon-22786
05/03/2023, 6:17 PMDOCKER_HOST
on the relevant machine?gentle-painting-24549
05/03/2023, 6:18 PM<tcp://localhost:2376>
witty-crayon-22786
05/03/2023, 6:19 PMunix://
domain sockets currentlygentle-painting-24549
05/03/2023, 6:20 PMdocker_environment
, right? Everything works as expected before adding the docker_environment
(except we can’t build PEX/Docker images on our macs)witty-crayon-22786
05/03/2023, 6:21 PMdocker_environment
implementation uses a native client library rather than forking the docker
cligentle-painting-24549
05/03/2023, 6:24 PMdocker_environments
when running on our macs, and use the default behavior when inside of CI/CD)witty-crayon-22786
05/03/2023, 6:27 PMtcp
vs unix
sockets in this context. is that a choice that you made when setting up Docker here?witty-crayon-22786
05/03/2023, 6:28 PMwitty-crayon-22786
05/03/2023, 6:30 PM2376
, an encrypted connection might be necessarygentle-painting-24549
05/03/2023, 6:35 PMwitty-crayon-22786
05/03/2023, 6:41 PMunix
vs tcp
aspect of this, but the TLS/SSL aspect is still unclear to me (it doesn’t get a unique address string, afaict).witty-crayon-22786
05/03/2023, 6:51 PMgentle-painting-24549
05/03/2023, 6:52 PMgentle-painting-24549
05/04/2023, 7:31 PMDOCKER_HOST
variable is updated to unix:///run/docker/docker.sock
inside our runners now.
However, I’m still running into issues on 2.15.1rc2
. When I have both a local_environment
and a docker_environment
specified (only my pex_binary
targets are specifically using this environment), I get this issue:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
When I remove the local_environment
and leave only the docker_environment
, I get the following issue:
Engine traceback:
in `publish` goal
in Building local distributions - environment:docker_x86
ProcessExecutionFailure: Process 'Extract environment variables from the Docker image python:3.8.16' failed with exit code 126.
stdout:
OCI runtime exec failed: exec failed: unable to start container process: chdir to cwd ("/pants-sandbox/pants-sandbox-nsMAG4") set in config.json failed: no such file or directory: unknown
witty-crayon-22786
05/04/2023, 7:53 PMwitty-crayon-22786
05/04/2023, 7:54 PMgentle-painting-24549
05/04/2023, 8:04 PMlocal_environment
(linux_x86) and one docker_environment
.
The local_environment
falls back to the docker_environment
so that CI/CD uses the local_environment
to build the pex and our Mac’s use the docker_environment
.
The issue there is that the DOCKER_HOST
environment variable doesn’t seem to get passed through so it’s looking for unix:///var/run/docker.sock
instead of unix:///run/docker/docker.sock
inside of CI/CDgentle-painting-24549
05/04/2023, 8:17 PMpants.ci.toml
or something like that?witty-crayon-22786
05/04/2023, 8:17 PMwitty-crayon-22786
05/04/2023, 8:19 PMgentle-painting-24549
05/04/2023, 8:20 PMwitty-crayon-22786
05/04/2023, 8:22 PMThefalls back to thelocal_environment
so that CI/CD uses thedocker_environment
to build the pex and our Mac’s use thelocal_environment
.docker_environment
The issue there is that thei’m not sure whether i understand the setup for this one: would you mind filing an issue about it?environment variable doesn’t seem to get passed through so it’s looking forDOCKER_HOST
instead ofunix:///var/run/docker.sock
inside of CI/CDunix:///run/docker/docker.sock
gentle-painting-24549
05/04/2023, 8:23 PMgentle-painting-24549
05/05/2023, 4:21 PM