first commit
This commit is contained in:
parent
0835a4d63c
commit
675ac0ca36
21 changed files with 401 additions and 0 deletions
9
docker_api/api/__init__.py
Normal file
9
docker_api/api/__init__.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from .containers import Containers
|
||||
from .images import Images
|
||||
|
||||
|
||||
class DockerManager:
|
||||
def __init__(self, docker_host):
|
||||
self.docker_host = docker_host
|
||||
self.containers = Containers(docker_host)
|
||||
self.images = Images(docker_host)
|
6
docker_api/api/base.py
Normal file
6
docker_api/api/base.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
import docker
|
||||
|
||||
|
||||
class Docker:
|
||||
def __init__(self, endpoint):
|
||||
self.client = docker.DockerClient(endpoint)
|
7
docker_api/api/containers.py
Normal file
7
docker_api/api/containers.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from .base import Docker
|
||||
|
||||
|
||||
class Containers(Docker):
|
||||
def list_containers(self):
|
||||
containers = self.client.containers.list()
|
||||
return containers
|
11
docker_api/api/images.py
Normal file
11
docker_api/api/images.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from .base import Docker
|
||||
|
||||
|
||||
class Images(Docker):
|
||||
def list_images(self):
|
||||
images = self.client.images.list()
|
||||
return images
|
||||
|
||||
def pull_image(self, repository):
|
||||
image = self.client.images.pull(repository)
|
||||
return image
|
Loading…
Add table
Add a link
Reference in a new issue