1
0
mirror of https://github.com/newnius/YAO-agent.git synced 2025-12-15 13:56:44 +00:00
This commit is contained in:
2019-03-12 16:28:04 +08:00
parent 4d9edef1fc
commit 71bd27f530
6 changed files with 169 additions and 4 deletions

22
executor.py Normal file
View File

@@ -0,0 +1,22 @@
import docker
def run():
client = docker.from_env()
#print(client.containers.run(image="alpine", command="echo 'Hello World'", environment={"KEY": "value"}))
print(client.containers.run(image="nvidia/cuda:9.0-base", command="nvidia-smi", environment={"KEY": "value"}, runtime="nvidia"))
def run_in_background():
client = docker.from_env()
container = client.containers.run("alpine", ["echo", "hello", "world"], detach=True)
print(container.id)
def list_containers():
client = docker.from_env()
for container in client.containers.list():
print(container.id)
run()