turn on container

This commit is contained in:
makram89 2022-01-27 21:48:00 +01:00
parent 0229e8fff7
commit 9248218bfd

View File

@ -7,6 +7,7 @@ class DockerManager:
def __init__(self): def __init__(self):
self.client = docker.from_env() self.client = docker.from_env()
self.image = 'felixlohmeier/openrefine'
def create_new_volume(self, username): def create_new_volume(self, username):
# Hashing username to get volume name # Hashing username to get volume name
@ -15,11 +16,14 @@ class DockerManager:
# Creating volume in docker # Creating volume in docker
volume = self.client.volumes.create(name=hashed_username, driver='local') volume = self.client.volumes.create(name=hashed_username, driver='local')
return hashed_username return volume.id
def turn_on_container(self, volume_id): def turn_on_container(self, volume_id, port):
pass container = self.client.containers.run(self.image, detach=True,
volumes={volume_id: {"bind": "/data", "mode": "rw"}})
def turn_off_container(self,volume_id): return container.id
def turn_off_container(self, volume_id, port):
pass pass