本文整理汇总了Python中docker.client.DockerClient方法的典型用法代码示例。如果您正苦于以下问题:Python client.DockerClient方法的具体用法?Python client.DockerClient怎么用?Python client.DockerClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docker.client
的用法示例。
在下文中一共展示了client.DockerClient方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: verify_container
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def verify_container(container: DockerClient, response_text: str) -> None:
config_data = get_config(container)
assert config_data["workers_per_core"] == 1
assert config_data["host"] == "0.0.0.0"
assert config_data["port"] == "80"
assert config_data["loglevel"] == "info"
assert config_data["workers"] >= 2
assert config_data["bind"] == "0.0.0.0:80"
logs = get_logs(container)
assert "Checking for script in /app/prestart.sh" in logs
assert "Running script /app/prestart.sh" in logs
assert (
"Running inside /app/prestart.sh, you could add migrations to this file" in logs
)
response = requests.get("http://127.0.0.1:8000")
assert response.text == response_text
示例2: verify_container
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def verify_container(container: DockerClient, response_text: str) -> None:
response = requests.get("http://127.0.0.1:8000")
assert response.text == response_text
config_data = get_config(container)
assert config_data["workers_per_core"] == 2
assert config_data["host"] == "0.0.0.0"
assert config_data["port"] == "8000"
assert config_data["loglevel"] == "warning"
assert config_data["bind"] == "0.0.0.0:8000"
assert config_data["graceful_timeout"] == 20
assert config_data["timeout"] == 20
assert config_data["keepalive"] == 20
assert config_data["errorlog"] is None
assert config_data["accesslog"] is None
logs = get_logs(container)
assert "Checking for script in /app/prestart.sh" in logs
assert "Running script /app/prestart.sh" in logs
assert (
"Running inside /app/prestart.sh, you could add migrations to this file" in logs
)
assert '"GET / HTTP/1.1" 200' not in logs
assert "[INFO] Application startup complete." not in logs
示例3: verify_container
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def verify_container(container: DockerClient, response_text: str) -> None:
response = requests.get("http://127.0.0.1:8000")
assert response.text == response_text
config_data = get_config(container)
assert config_data["workers_per_core"] == 1
assert config_data["use_max_workers"] is None
assert config_data["host"] == "0.0.0.0"
assert config_data["port"] == "80"
assert config_data["loglevel"] == "info"
assert config_data["workers"] >= 2
assert config_data["bind"] == "0.0.0.0:80"
assert config_data["graceful_timeout"] == 120
assert config_data["timeout"] == 120
assert config_data["keepalive"] == 5
assert config_data["errorlog"] == "-"
assert config_data["accesslog"] == "-"
logs = get_logs(container)
assert "Checking for script in /app/prestart.sh" in logs
assert "Running script /app/prestart.sh" in logs
assert (
"Running inside /app/prestart.sh, you could add migrations to this file" in logs
)
assert '"GET / HTTP/1.1" 200' in logs
assert "[INFO] Application startup complete." in logs
assert "Using worker: uvicorn.workers.UvicornWorker" in logs
示例4: verify_container
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def verify_container(container: DockerClient, response_text: str) -> None:
config_data = get_config(container)
process_names = get_process_names(container)
config_data = get_config(container)
assert config_data["workers"] == 1
assert len(process_names) == 2 # Manager + worker
assert config_data["host"] == "127.0.0.1"
assert config_data["port"] == "9000"
assert config_data["bind"] == "0.0.0.0:8080"
assert config_data["use_max_workers"] == 1
logs = get_logs(container)
assert "Checking for script in /app/prestart.sh" in logs
assert "Running script /app/prestart.sh" in logs
assert (
"Running inside /app/prestart.sh, you could add migrations to this file" in logs
)
response = requests.get("http://127.0.0.1:8000")
assert response.text == response_text
示例5: cfg
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def cfg(mocker):
from deck_chores.config import cfg
cfg.client = mocker.MagicMock(DockerClient)
cfg.client.api = mocker.MagicMock(APIClient)
cfg.debug = True
cfg.default_max = 1
cfg.default_flags = split_string('image,service', sort=True)
cfg.default_user = 'root'
cfg.label_ns = 'deck-chores.'
cfg.service_identifiers = split_string('project_id,service_id')
cfg.timezone = 'UTC'
job_config_validator.set_defaults(cfg)
yield cfg
示例6: docker_client
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def docker_client() -> DockerClient:
"""
Return a Docker client.
"""
try:
return docker.from_env(version='auto')
except docker.errors.DockerException:
message = (
'Error: Cannot connect to Docker.\n'
'Make sure that Docker is installed and running, '
'and that you can run "docker ps".\n'
'If "sudo docker ps" works, try following the instructions at '
'https://docs.docker.com/install/linux/linux-postinstall/.'
)
click.echo(message, err=True)
sys.exit(1)
示例7: remove_previous_container
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def remove_previous_container(client: DockerClient) -> None:
try:
previous = client.containers.get(CONTAINER_NAME)
previous.stop()
previous.remove()
except NotFound:
return None
示例8: get_logs
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def get_logs(container: DockerClient) -> str:
logs = container.logs()
return logs.decode("utf-8")
示例9: verify_container
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def verify_container(container: DockerClient, response_text: str) -> None:
response = requests.get("http://127.0.0.1:8000")
data = response.json()
assert data["message"] == response_text
config_data = get_config(container)
assert config_data["workers_per_core"] == 1
assert config_data["use_max_workers"] is None
assert config_data["host"] == "0.0.0.0"
assert config_data["port"] == "80"
assert config_data["loglevel"] == "info"
assert config_data["workers"] >= 2
assert config_data["bind"] == "0.0.0.0:80"
assert config_data["graceful_timeout"] == 120
assert config_data["timeout"] == 120
assert config_data["keepalive"] == 5
assert config_data["errorlog"] == "-"
assert config_data["accesslog"] == "-"
logs = get_logs(container)
assert "Checking for script in /app/prestart.sh" in logs
assert "Running script /app/prestart.sh" in logs
assert (
"Running inside /app/prestart.sh, you could add migrations to this file" in logs
)
assert '"GET / HTTP/1.1" 200' in logs
assert "[INFO] Application startup complete." in logs
assert "Using worker: uvicorn.workers.UvicornWorker" in logs
示例10: verify_container
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def verify_container(container: DockerClient, response_text: str) -> None:
gunicorn_conf_path = get_gunicorn_conf_path(container)
config_data = get_config(container)
assert gunicorn_conf_path == "/app/gunicorn_conf.py"
assert config_data["loglevel"] == "warning"
assert config_data["workers"] == 3
assert config_data["bind"] == "0.0.0.0:8000"
logs = get_logs(container)
assert "Checking for script in /app/prestart.sh" in logs
assert "Running script /app/prestart.sh" in logs
assert (
"Running inside /app/prestart.sh, you could add migrations to this file" in logs
)
response = requests.get("http://127.0.0.1:8000")
assert response.text == response_text
示例11: verify_container
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def verify_container(container: DockerClient, response_text: str) -> None:
gunicorn_conf_path = get_gunicorn_conf_path(container)
config_data = get_config(container)
assert gunicorn_conf_path == "/app/app/gunicorn_conf.py"
assert config_data["loglevel"] == "warning"
assert config_data["workers"] == 3
assert config_data["bind"] == "0.0.0.0:8000"
logs = get_logs(container)
assert "Checking for script in /app/prestart.sh" in logs
assert "Running script /app/prestart.sh" in logs
assert (
"Running inside /app/prestart.sh, you could add migrations to this file" in logs
)
response = requests.get("http://127.0.0.1:8000")
assert response.text == response_text
示例12: verify_container
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def verify_container(
container: DockerClient, response_text: str, prestart_str: str
) -> None:
config_data = get_config(container)
assert config_data["workers_per_core"] == 1
assert config_data["host"] == "0.0.0.0"
assert config_data["port"] == "80"
assert config_data["loglevel"] == "info"
assert config_data["workers"] >= 2
assert config_data["bind"] == "0.0.0.0:80"
logs = get_logs(container)
assert prestart_str in logs
response = requests.get("http://127.0.0.1:8000")
assert response.text == response_text
示例13: verify_container
# 需要导入模块: from docker import client [as 别名]
# 或者: from docker.client import DockerClient [as 别名]
def verify_container(container: DockerClient, response_text: str) -> None:
logs = get_logs(container)
assert "Checking for script in /app/prestart.sh" in logs
assert "Running script /app/prestart.sh" in logs
assert (
"Running inside /app/prestart.sh, you could add migrations to this file" in logs
)
assert "Uvicorn running on http://0.0.0.0:80" in logs
response = requests.get("http://127.0.0.1:8000")
assert response.text == response_text