Step 1:
pip install docker
pip install tqdm
Step 2:
import docker
c = docker.from_env()
p = c.images.pull('gitlab-registry.cern.ch/atrisovi/test-dockint')
img = c.images.get('gitlab-registry.cern.ch/atrisovi/test-dockint:hello')
f = open('/tmp/hello-world.tar','w')
resp = img.save()
import tqdm
for chunk in tqdm.tqdm(resp.stream(), leave=True, miniters=1):
... f.write(chunk)
...
1it [00:00, 1183.49it/s]
f.close()
exit()
Other
client.images.list()
gitlab registry
from image_importer import ImageImporter
ii = ImageImporter()
ii.archive_image("gitlab-registry.cern.ch/atrisovi/test-dockint:hello", "tmp")
dockerhub
from image_importer import ImageImporter
ii = ImageImporter()
ii.archive_image("atrisovic/rootexample", "tmp")
Repo importer:
from repo_importer import RepoImporter
ri = RepoImporter.create("https://gitlab.cern.ch/atrisovi/root-examples")
s, a = ri.archive_repository()
s
212037
with open("file_repo.tar.gz","w") as f:
... f.write(a)
...