Open bennythejudge opened 2 years ago
while another job, executing a Pipeline, gets the error in title:
Can you post your Jenkinsfile? I would say your "other job" runs inside a container so buildx is not available in it but the first "shell step" runs on the host?
Also be careful with docker buildx create --node multiarch --use
because it will create as many builders you run this workflow. Check on your host docker buildx ls
, I guess you have a bunch of builders in there.
If you still want to create a builder for each run of this workflow, you might need to remove it in a post section like:
stages {
stage('Create builder') {
steps {
sh "docker buildx create --name builder-${env.BUILD_ID} --use"
}
}
}
post {
always {
sh "docker buildx rm builder-${env.BUILD_ID} --keep-state" // remove mybuilder but keep BuildKit state
}
}
Also using --node
might not be what you want here but --name
to specify the builder name. I specify env.BUILD_ID
so it creates a dedicated builder linked to the current invocation in your pipeline and doesn't overlap with another one. --keep-state
flag keeps BuildKit state volume on your host so next run of this build will leverage a bit of caching.
But if a single builder is ok, then just create the builder on your host and remove buildx create/rm
steps in your workflow.
Hi, apologies in advance, because it feels like my issue is not really a buildx issue per se but an environment issue and yet I don't know where else to ask for help.
I have a Jenkins worker running in AWS on an EC2 with Amazon Linux2 where I have installed
docker
20.10.7 andbuildx
0.8.2. A simple Jenkins job with a shell step can invoke the commanddocker buildx create --node multiarch --use
, while another job, executing a Pipeline, gets the error in title:First case:
Pipeline with error:
They are running on the same EC2, as the same user (
ec2-user
), in different directories but withbuildx
present in both cases under$HOME/.docker/cli-plugins/docker-buildx
.In the second case, it looks like docker is not "detecting" the presence of the
buildx
binary at all. I have compared the output ofenv
in both cases and I couldn't see any noticeable difference (with the exception perhaps ofSHLVL
which is 2 in the working case, and 3 in the non-working one.What am I doing wrong? What have I disregarded? Has anyone got any idea? Thanks