Docker-Docker SDK for Python
- 官方文档 :https://docker-py.readthedocs.io/en/stable/images.html
- 安装方式pip :pip install docker -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
- 使用python安装 :克隆项目 :https://github.com/docker/docker-py ,python3 install setup.py
官方给出的一些方法
其他的读取当前docker环境中的一些方法如:
client.images([name]) 获取镜像信息,name可以是一个镜像的name,name的一部分,name:tag等多种形式,获取到完整的镜像信息。不指定name时返回所有镜像信息
client.containers([name]) 获取容器信息,name可以是容器的name, id等等,返回
client.info() docker info命令的那些输出
client.start/stop(name) 相当于docker start和stop制定容器
...
上述几个方法的输出都是标准的JSON格式,可以很方便地被嵌入到其他的一些系统中
client.login() 可以传入实名参数username, password, registry等,相当于docker login
cli.adapters cli.headers cli.proxies
cli.api_version cli.history cli.pull
cli.attach cli.hooks cli.push
cli.attach_socket cli.images cli.put
cli.auth cli.import_image cli.put_archive
cli.base_url cli.import_image_from_data cli.rebuild_auth
cli.build cli.import_image_from_file cli.rebuild_method
cli.cert cli.import_image_from_image cli.rebuild_proxies
cli.close cli.import_image_from_stream cli.remove_container
cli.commit cli.import_image_from_url cli.remove_image
cli.connect_container_to_network cli.info cli.remove_network
cli.containers cli.init_swarm cli.remove_service
cli.cookies cli.insert cli.remove_volume
cli.copy cli.inspect_container cli.rename
cli.create_container cli.inspect_image cli.request
cli.create_container_config cli.inspect_network cli.resize
cli.create_container_from_config cli.inspect_node cli.resolve_redirects
cli.create_endpoint_config cli.inspect_service cli.restart
cli.create_host_config cli.inspect_swarm cli.search
cli.create_network cli.inspect_task cli.send
cli.create_networking_config cli.inspect_volume cli.services
cli.create_service cli.join_swarm cli.start
cli.create_swarm_spec cli.kill cli.stats
cli.create_volume cli.leave_swarm cli.stop
cli.delete cli.load_image cli.stream
cli.diff cli.login cli.tag
cli.disconnect_container_from_network cli.logs cli.tasks
cli.events cli.max_redirects cli.timeout
cli.exec_create cli.merge_environment_settings cli.top
cli.exec_inspect cli.mount cli.trust_env
cli.exec_resize cli.networks cli.unpause
cli.exec_start cli.nodes cli.update_container
cli.export cli.options cli.update_service
cli.from_env cli.params cli.update_swarm
cli.get cli.patch cli.verify
cli.get_adapter cli.pause cli.version
cli.get_archive cli.ping cli.volumes
cli.get_image cli.port cli.wait
cli.get_redirect_target cli.post
cli.head cli.prepare_request
向往的地方很远,喜欢的东西很贵,这就是我努力的目标。