Using docker API with python SDK https://docker-py.readthedocs.io/en/stable
import docker
client = docker.from_env()
client.containers.run('alpine', 'echo hello world')
import docker
client = docker.from_env()
client.containers.create(image='jupyterhub-notebook-gpu-nvidia:stable', command='', runtime='nvidia')import docker
import os
cert_path = "..."
tls_config = docker.tls.TLSConfig(
client_cert=(os.path.join(cert_path, 'cert.pem'),
os.path.join(cert_path, 'key.pem')),
ca_cert=os.path.join(cert_path, 'ca.pem'),
verify=True,
assert_hostname=False,
)
client = docker.DockerClient(base_url="https://192.168.99.100:2376", tls=tls_config)
containers = client.containers.list()python3 - <<EOF
import docker
client = docker.from_env()
client.containers.create(image='jupyterhub-notebook-gpu-nvidia:stable', command='', runtime='nvidia')
EOF