當前位置: 首頁>>代碼示例>>Python>>正文


Python client.DockerClient方法代碼示例

本文整理匯總了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 
開發者ID:tiangolo,項目名稱:uvicorn-gunicorn-docker,代碼行數:18,代碼來源:test_package_app.py

示例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 
開發者ID:tiangolo,項目名稱:uvicorn-gunicorn-docker,代碼行數:24,代碼來源:test_env_vars_1.py

示例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 
開發者ID:tiangolo,項目名稱:uvicorn-gunicorn-docker,代碼行數:27,代碼來源:test_defaults.py

示例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 
開發者ID:tiangolo,項目名稱:uvicorn-gunicorn-docker,代碼行數:20,代碼來源:test_env_vars_3.py

示例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 
開發者ID:funkyfuture,項目名稱:deck-chores,代碼行數:18,代碼來源:conftest.py

示例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) 
開發者ID:dcos,項目名稱:dcos-e2e,代碼行數:18,代碼來源:_common.py

示例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 
開發者ID:tiangolo,項目名稱:uwsgi-nginx-docker,代碼行數:9,代碼來源:utils.py

示例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") 
開發者ID:tiangolo,項目名稱:uvicorn-gunicorn-fastapi-docker,代碼行數:5,代碼來源:utils.py

示例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 
開發者ID:tiangolo,項目名稱:uvicorn-gunicorn-fastapi-docker,代碼行數:28,代碼來源:test_defaults.py

示例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 
開發者ID:tiangolo,項目名稱:uvicorn-gunicorn-docker,代碼行數:17,代碼來源:test_package_app_config.py

示例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 
開發者ID:tiangolo,項目名稱:uvicorn-gunicorn-docker,代碼行數:17,代碼來源:test_package_app_sub_config.py

示例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 
開發者ID:tiangolo,項目名稱:uvicorn-gunicorn-docker,代碼行數:16,代碼來源:test_custom_app.py

示例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 
開發者ID:tiangolo,項目名稱:uvicorn-gunicorn-docker,代碼行數:12,代碼來源:test_defaults.py


注:本文中的docker.client.DockerClient方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。