When curl isn’t available inside a container

If troubleshooting inside a container that does not have curl installed and also doesn’t permit installing then an option is to use a curl binary that has been statically compiled.

There are a list of curl binaries here download one matching the arch of your container then extract it with e.g.

tar -xf curl-linux-x86_64-glibc-8.11.1.tar.xz

Then copy the extract binary to the container e.g.

kubectl cp ./curl argocd/argocd-repo-server-6f5ff4d459-88ngg:/tmp/curl

Then use it, for example to pull the service account token:

/tmp/curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token

For reference I needed this when inside an argocd-repo-server container when testing access permissions and workload identity. I then used the token

/tmp/curl -H "Authorization: Bearer $ACCESS_TOKEN" \
  https://us-docker.pkg.dev/v2/acme-corp/some-repo/some-package/tags/list

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>