Python docker SDK content trust not working

Viewed 227

I want to enable content trust when pulling images from the python docker sdk but currently I am doing:

export DOCKER_CONTENT_TRUST=1

and then in python3 I do:

import docker
client = docker.from_env()
client.images.pull('some-image-with-no-remote-trust-data')

but it pulls the image successfully.

doing:

docker pull some-image-with-no-remote-trust-data

gives me the error: Error: remote trust data does not exist...


I expect to get a similar error when pulling with python sdk but I don't... how do I fix this?

1 Answers

Currently it seems like this feature is not supported - https://github.com/docker/docker-py/issues/1773

What I suggest is to use subprocess

import subprocess
ret = subprocess.run(['docker', 'pull', 'some-image-with-no-remote-trust-data'])
if ret.returncode:
    # pull failed
    pass
Related