I’m getting the following output running `./pants ...
# general
n
I’m getting the following output running
./pants publish
for a docker image
Copy code
17:32:51.78 [TRACE] Completed: pants.core.goals.publish.package_for_publish
log: failed to find directory: exec: "sh": executable file not found in $PATHThe push refers to repository [<http://888845.dkr.ecr.us-east-1.amazonaws.com/8/example|888845.dkr.ecr.us-east-1.amazonaws.com/8/example>]
780d01aa651c: Preparing
Any ideas? This is with 2.9.0rc6.
👀 1
c
Looks strange. As it seems you've got some output from the docker push there..
I’m off for today, but can take another look tomorrow.
As it seems the image packaging finished (
Completed: pants.core.goals.publish.package_for_publish
) and the docker push was under way (
The push refers to repository [<http://888845.dkr.ecr.us-east-1.amazonaws.com/8/example|888845.dkr.ecr.us-east-1.amazonaws.com/8/example>]
) could that error be from something else?
What more where being packaged, for instance? Do you have any
experimental_shell_command
targets, for instance?
what targets where you operating on? (was it just one single
docker_image
?)
n
Just a single docker image target in the build file. I’ve stripped things back now - seems that message only appears when the registries definition is added. I removed any config in
pants.toml
.
Copy code
docker_image(
    name="example",
    repository="example/image",
    registries=["<http://99999999.dkr.ecr.us-east-1.amazonaws.com|99999999.dkr.ecr.us-east-1.amazonaws.com>"],
)
It waits on
log: failed to find directory: exec: "sh": executable file not found in $PATH
for about 5 seconds. If i comment out registries, i don’t get that message and there is no delay. The publish fails later as expected due to auth with docker.io.
This is running on a mac.
c
Ugh. Well, that was strange. I’ll see if I can repro with that example.
Does it build ok in both situations (with and without the registries)?
n
Yes, build is fine
👍 1
c
Hmm… I can’t repro based on what I see above, at least..
Copy code
11:31:37.76 [INFO] Built docker image: <http://99999999.dkr.ecr.us-east-1.amazonaws.com/example/image:latest|99999999.dkr.ecr.us-east-1.amazonaws.com/example/image:latest>
11:31:37.76 [TRACE] Completed: pants.backend.docker.goals.publish.push_docker_images
11:31:37.76 [TRACE] Completed: pants.core.goals.publish.package_for_publish
The push refers to repository [<http://99999999.dkr.ecr.us-east-1.amazonaws.com/example/image|99999999.dkr.ecr.us-east-1.amazonaws.com/example/image>]
cf8c8c8b5a23: Preparing 
d09836256ed7: Preparing 
984d2bf694d9: Preparing 
5e2d6061e5d9: Preparing 
aedcb370b058: Preparing 
c3a0d593ed24: Waiting 
26a504e63be4: Waiting 
8bf42db0de72: Waiting 
31892cc314cb: Waiting 
11936051f93b: Waiting 
no basic auth credentials

𐄂 <http://99999999.dkr.ecr.us-east-1.amazonaws.com/example/image:latest|99999999.dkr.ecr.us-east-1.amazonaws.com/example/image:latest> failed.
11:31:38.63 [DEBUG] Publish result data:
[
  {
    "exit_code": 1,
    "names": [
      "<http://99999999.dkr.ecr.us-east-1.amazonaws.com/example/image:latest|99999999.dkr.ecr.us-east-1.amazonaws.com/example/image:latest>"
    ],
    "published": false,
    "publisher": "docker",
    "registries": [
      "<http://99999999.dkr.ecr.us-east-1.amazonaws.com|99999999.dkr.ecr.us-east-1.amazonaws.com>"
    ],
    "status": "failed",
    "target": "src/docker/hello_world:python"
  }
]
11:31:38.63 [DEBUG] Completed: `publish` goal
Built and published fine (i.e. publish failed due to auth, naturally) but no delays or other errors. Using this BUILD target:
Copy code
docker_image(
    name="python",
    source="Dockerfile.python",

    repository="example/image",
    registries=["<http://99999999.dkr.ecr.us-east-1.amazonaws.com|99999999.dkr.ecr.us-east-1.amazonaws.com>"],
)
and no docker related config in
pants.toml
or env or rc files.
This on pants 2.9.0
n
Hmm still getting it on 2.9.0, but not when running pants built from current
main
with
./pants publish testprojects/src/python/docker/Dockerfile.example
. Can try again with local 2.9.0 build.
It seems it only happens with a valid ECR registry domain. Am able to replicate with the test project using
Copy code
docker_image(
    name="test-example",
    image_tags=["1.2.5"],
    source="Dockerfile.example",
    repository="example/image",
    registries=["public.ecr.aws"],
)
c
Aha, interesting. Would seem that the docker client shells out using
sh
in that case, and since we’re sandboxed,
sh
is not available on
$PATH
.
👍 1
I had no issue with that last example either:
Copy code
12:53:37.76 [INFO] Built docker image: public.ecr.aws/example/image:latest
12:53:37.76 [TRACE] Completed: pants.backend.docker.goals.publish.push_docker_images
12:53:37.76 [TRACE] Completed: pants.core.goals.publish.package_for_publish
The push refers to repository [public.ecr.aws/example/image]
cf8c8c8b5a23: Preparing 
d09836256ed7: Preparing 
984d2bf694d9: Preparing 
5e2d6061e5d9: Preparing 
aedcb370b058: Preparing 
c3a0d593ed24: Waiting 
26a504e63be4: Waiting 
8bf42db0de72: Waiting 
31892cc314cb: Waiting 
11936051f93b: Waiting 
denied: Not Authorized

𐄂 public.ecr.aws/example/image:latest failed.
12:53:39.67 [DEBUG] Publish result data:
[
  {
    "exit_code": 1,
    "names": [
      "public.ecr.aws/example/image:latest"
    ],
    "published": false,
    "publisher": "docker",
    "registries": [
      "public.ecr.aws"
    ],
    "status": "failed",
    "target": "src/docker/hello_world:python"
  }
]
12:53:39.67 [DEBUG] Completed: `publish` goal
Could it be possible that you have some configuration or plugin for AWS in your docker setup?
n
Yes! The ecr-login cred helper. Hadn’t looked into it but was confused auth wasn’t just working as it should. https://github.com/awslabs/amazon-ecr-credential-helper
c
Ah, there we have it!
Can you figure out what needs to be on PATH for it to work?
apparently,
sh
is one, but question is if that is enough..?
hmm… seems like this one too:
docker-credential-ecr-login
👍 1
So, this ought to be configurable, in some way. I’ll see what makes most sense here..
n
Yes. It will likely also need access to ``~/.aws/credentials`` and
~/.aws/config
Let me know if there’s anything I can help with.
c
Will do, thanks.
e
👀
Also interested in how to get pants to work with ECR auth/amazon-ecr-credential-helper. As is we have to make sure to manually
docker pull ...
before a
./pants package
👍 1
c
Thanks for the bump @eager-dress-66405. I’ve had a lot of other things going on else where, I’ll circle back to this as soon as I manage to free up some time.
🙏 1