docker remote api
2021-05-23 15:28
标签:ORC 三种方式 pytho docker ops pull ima decode docke Docke client python sdk #!/usr/bin/python c = docker.from.env() #pull auth_config = { #push remote api XRA= curl -XPOST -H "X-Registry-Auth: $XRA" \ docker remote api 标签:ORC 三种方式 pytho docker ops pull ima decode docke 原文地址:https://blog.51cto.com/aegis8/2417026
首先下载pip install docker
import sys, json, docker.from.env()
try:
client.ping()
except dock.errors.APIError:
print("docker connect failed")
sys.exit(1)
for line in c.api.pull(‘nginx‘, stream=True, decode=True):
print(json.denps(line, indent=4))
#tag
tag = opshar.xxxx.com/app/nginx
try:
c.api.tag(‘nginx‘, tag, ‘latest‘, force=True)
except docker.errors.APIError:
print("tag failed")
sys.exit(1)
"username": "admin",
"password": "Harbor12345"
}
for line in c.api.push(tag, stream=True, decode=True, auth_config=auth_config):
print(json.denps(line, indent=4))
#pull
curl -XPOST http://IP:2375/images/create?fromImage=nginx
#TAG
curl -XPOST http://IP:2375/images/hello-world/tag?repo=opshar.xxxx.com/app/nginxPUSH
echo ‘{"username": "admin","password": "Harbor12345", "serveraddress": "opshar.xxxx.com"}‘ | base64 --wrap=0
http://IP:2375/images/opshar.xxxx.com/app/nginx
下一篇:C# IPC信道跨进程通信