docker-py icon indicating copy to clipboard operation
docker-py copied to clipboard

SSH option missing from the python client

Open agyoungs opened this issue 2 years ago • 4 comments

Maybe I missed it, but it appears that the --ssh option is missing from the python client. This option provides the SSH agent socket or keys from the host to the build. (e.g. docker build --ssh=default ...)

Am I missing something obvious here or is this option not provided?

agyoungs avatar Sep 27 '23 03:09 agyoungs

docker-py is a wrapper for docker engine API & it seems the ssh option is not available. https://docs.docker.com/engine/api/v1.43/#tag/Image/operation/ImageBuild

as workaround, u can use build arg & pass ssh to it.

naufalafif avatar Sep 29 '23 09:09 naufalafif

@naufalafif Thanks for the reply and I've since realized that the --ssh feature was unfortunately not available with the Docker Engine API.

How would I use build args as a workaround? As I understand I would use ARG SSH in the Dockerfile, but I'm not sure how I would be able to use the agent in the docker build environment to clone a repo or something similar.

agyoungs avatar Sep 29 '23 19:09 agyoungs

You're correct - this is not possible using the API via the Python bindings, which only support the classic builder and not BuildKit.

For now, the best option (although not ideal) is to shell out to docker buildx.

milas avatar Nov 21 '23 15:11 milas