| 686 | |
| 687 | |
| 688 | class ContainerConfig(dict): |
| 689 | def __init__( |
| 690 | self, version, image, command, hostname=None, user=None, detach=False, |
| 691 | stdin_open=False, tty=False, ports=None, environment=None, |
| 692 | volumes=None, network_disabled=False, entrypoint=None, |
| 693 | working_dir=None, domainname=None, host_config=None, mac_address=None, |
| 694 | labels=None, stop_signal=None, networking_config=None, |
| 695 | healthcheck=None, stop_timeout=None, runtime=None |
| 696 | ): |
| 697 | |
| 698 | if stop_timeout is not None and version_lt(version, '1.25'): |
| 699 | raise errors.InvalidVersion( |
| 700 | 'stop_timeout was only introduced in API version 1.25' |
| 701 | ) |
| 702 | |
| 703 | if healthcheck is not None: |
| 704 | if version_lt(version, '1.24'): |
| 705 | raise errors.InvalidVersion( |
| 706 | 'Health options were only introduced in API version 1.24' |
| 707 | ) |
| 708 | |
| 709 | if version_lt(version, '1.29') and 'StartPeriod' in healthcheck: |
| 710 | raise errors.InvalidVersion( |
| 711 | 'healthcheck start period was introduced in API ' |
| 712 | 'version 1.29' |
| 713 | ) |
| 714 | |
| 715 | if isinstance(command, str): |
| 716 | command = split_command(command) |
| 717 | |
| 718 | if isinstance(entrypoint, str): |
| 719 | entrypoint = split_command(entrypoint) |
| 720 | |
| 721 | if isinstance(environment, dict): |
| 722 | environment = format_environment(environment) |
| 723 | |
| 724 | if isinstance(labels, list): |
| 725 | labels = {lbl: '' for lbl in labels} |
| 726 | |
| 727 | if isinstance(ports, list): |
| 728 | exposed_ports = {} |
| 729 | for port_definition in ports: |
| 730 | port = port_definition |
| 731 | proto = 'tcp' |
| 732 | if isinstance(port_definition, tuple): |
| 733 | if len(port_definition) == 2: |
| 734 | proto = port_definition[1] |
| 735 | port = port_definition[0] |
| 736 | exposed_ports[f'{port}/{proto}'] = {} |
| 737 | ports = exposed_ports |
| 738 | |
| 739 | if isinstance(volumes, str): |
| 740 | volumes = [volumes, ] |
| 741 | |
| 742 | if isinstance(volumes, list): |
| 743 | volumes_dict = {} |
| 744 | for vol in volumes: |
| 745 | volumes_dict[vol] = {} |
no outgoing calls