
                             S SK r S SKrS SKJr  SSKJr  SSKJr  SSKJ	r	J
r
JrJrJr  SSKJr  SSKJr  S	S
KJr  S	SKJrJr   " S S\5      r " S S\5      r/ SQr/ SQrS rS r\" SS5      rg)    N)
namedtuple   )	APIClient)DEFAULT_DATA_CHUNK_SIZE)ContainerErrorDockerExceptionImageNotFoundNotFoundcreate_unexpected_kwargs_error)
HostConfig)version_gte   )Image)
CollectionModelc                      \ rS rSrSr\S 5       r\S 5       r\S 5       r\S 5       r	\S 5       r
S rS	 rS!S jrS r   S"S jr\4S jr\S4S jrS#S jrS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"g
)$	Container   a$  Local representation of a container object. Detailed configuration may
be accessed through the :py:attr:`attrs` attribute. Note that local
attributes are cached; users may call :py:meth:`reload` to
query the Docker daemon for the current properties, causing
:py:attr:`attrs` to be refreshed.
c                 x    U R                   R                  S5      b  U R                   S   R                  S5      $ g)z
The name of the container.
NameN/)attrsgetlstripselfs    +lib/third_party/docker/models/containers.pynameContainer.name   s6    
 ::>>&!-::f%,,S11 .    c                     U R                   R                  SU R                   S   5      nUc  gU R                  R                  R                  UR	                  S5      S   5      $ )z
The image of the container.
ImageIDr   N:r   )r   r   clientimagessplit)r   image_ids     r   imageContainer.image    sS    
 ::>>)TZZ-@A{{!!%%hnnS&9!&<==r    c                      U R                   S   R                  S5      nU=(       d    0 $ ! [         a    [        S5      ef = f)z*
The labels of a container as dictionary.
ConfigLabelszYLabel data is not available for sparse objects. Call reload() to retrieve all information)r   r   KeyErrorr   )r   results     r   labelsContainer.labels*   sK    
	ZZ)--h7F<R 	!/ 	s	   (+ Ac                     [        U R                  S   [        5      (       a  U R                  S   S   $ U R                  S   $ )zG
The status of the container. For example, ``running``, or ``exited``.
StateStatus)
isinstancer   dictr   s    r   statusContainer.status8   s=    
 djj)400::g&x00zz'""r    c                 Z    U R                   R                  S0 5      R                  S0 5      $ )z7
The ports that the container exposes as a dictionary.
NetworkSettingsPorts)r   r   r   s    r   portsContainer.portsA   s'    
 zz~~/488"EEr    c                 d    U R                   R                  R                  " U R                  40 UD6$ )a  
Attach to this container.

:py:meth:`logs` is a wrapper around this method, which you can
use instead if you want to fetch/stream container output without first
retrieving the entire backlog.

Args:
    stdout (bool): Include stdout.
    stderr (bool): Include stderr.
    stream (bool): Return container output progressively as an iterator
        of strings, rather than a single string.
    logs (bool): Include the container's previous output.

Returns:
    By default, the container's output as a single string.

    If ``stream=True``, an iterator of output strings.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   apiattachidr   kwargss     r   r?   Container.attachH   s&    0 {{%%dgg888r    c                 d    U R                   R                  R                  " U R                  40 UD6$ )aV  
Like :py:meth:`attach`, but returns the underlying socket-like object
for the HTTP request.

Args:
    params (dict): Dictionary of request parameters (e.g. ``stdout``,
        ``stderr``, ``stream``).
    ws (bool): Use websockets instead of raw HTTP.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   attach_socketr@   rA   s     r   rE   Container.attach_socketb   s&     {{,,TWW???r    Nc                     U R                   R                  R                  " U R                  4XS.UD6nU R                   R                  R                  US   5      $ )aT  
Commit a container to an image. Similar to the ``docker commit``
command.

Args:
    repository (str): The repository to push the image to
    tag (str): The tag to push
    message (str): A commit message
    author (str): The name of the author
    changes (str): Dockerfile instructions to apply while committing
    conf (dict): The configuration for the container. See the
        `Engine API documentation
        <https://docs.docker.com/reference/api/docker_remote_api/>`_
        for full details.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)
repositorytagId)r$   r>   commitr@   r%   r   )r   rH   rI   rB   resps        r   rK   Container.commitr   sP    * {{%%dgg 0* 0(.0{{!!%%d4j11r    c                 `    U R                   R                  R                  U R                  5      $ )z
Inspect changes on a container's filesystem.

Returns:
    (list) A list of dictionaries containing the attributes `Path`
        and `Kind`.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   diffr@   r   s    r   rO   Container.diff   s!     {{##DGG,,r    Fc                 X   U R                   R                  R                  U R                  XX4UXgUUS9
nU R                   R                  R	                  US   XXUS9nU
(       d  U	(       a  [        SU5      $ [        U R                   R                  R                  US   5      S   U5      $ )a!  
Run a command inside this container. Similar to
``docker exec``.

Args:
    cmd (str or list): Command to be executed
    stdout (bool): Attach to stdout. Default: ``True``
    stderr (bool): Attach to stderr. Default: ``True``
    stdin (bool): Attach to stdin. Default: ``False``
    tty (bool): Allocate a pseudo-TTY. Default: False
    privileged (bool): Run as privileged.
    user (str): User to execute command as. Default: root
    detach (bool): If true, detach from the exec command.
        Default: False
    stream (bool): Stream response data. Default: False
    socket (bool): Return the connection socket to allow custom
        read/write operations. Default: False
    environment (dict or list): A dictionary or a list of strings in
        the following format ``["PASSWORD=xxx"]`` or
        ``{"PASSWORD": "xxx"}``.
    workdir (str): Path to working directory for this exec session
    demux (bool): Return stdout and stderr separately

Returns:
    (ExecResult): A tuple of (exit_code, output)
        exit_code: (int):
            Exit code for the executed command or ``None`` if
            either ``stream`` or ``socket`` is ``True``.
        output: (generator, bytes, or tuple):
            If ``stream=True``, a generator yielding response chunks.
            If ``socket=True``, a socket object for the connection.
            If ``demux=True``, a tuple of two bytes: stdout and stderr.
            A bytestring containing response data otherwise.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)stdoutstderrstdintty
privilegeduserenvironmentworkdirrJ   )detachrU   streamsocketdemuxNExitCode)r$   r>   exec_creater@   
exec_start
ExecResultexec_inspect)r   cmdrR   rS   rT   rU   rV   rW   rZ   r[   r\   rX   rY   r]   rL   exec_outputs                   r   exec_runContainer.exec_run   s    R {{**GGS!+ + 

 kkoo00Jvv 1 
 VdK00KKOO((d4Z@
 	
r    c                 b    U R                   R                  R                  U R                  U5      $ )a  
Export the contents of the container's filesystem as a tar archive.

Args:
    chunk_size (int): The number of bytes returned by each iteration
        of the generator. If ``None``, data will be streamed as it is
        received. Default: 2 MB

Returns:
    (str): The filesystem tar archive

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   exportr@   )r   
chunk_sizes     r   rh   Container.export   s#      {{%%dggz::r    c                 d    U R                   R                  R                  U R                  UX#5      $ )a  
Retrieve a file or folder from the container in the form of a tar
archive.

Args:
    path (str): Path to the file or folder to retrieve
    chunk_size (int): The number of bytes returned by each iteration
        of the generator. If ``None``, data will be streamed as it is
        received. Default: 2 MB
    encode_stream (bool): Determines if data should be encoded
        (gzip-compressed) during transmission. Default: False

Returns:
    (tuple): First element is a raw tar data stream. Second element is
    a dict containing ``stat`` information on the specified ``path``.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.

Example:

    >>> f = open('./sh_bin.tar', 'wb')
    >>> bits, stat = container.get_archive('/bin/sh')
    >>> print(stat)
    {'name': 'sh', 'size': 1075464, 'mode': 493,
     'mtime': '2018-10-01T15:37:48-07:00', 'linkTarget': ''}
    >>> for chunk in bits:
    ...    f.write(chunk)
    >>> f.close()
)r$   r>   get_archiver@   )r   pathri   encode_streams       r   rl   Container.get_archive   s-    B {{**477D+5F 	Fr    c                 ^    U R                   R                  R                  U R                  US9$ )z
Kill or send a signal to the container.

Args:
    signal (str or int): The signal to send. Defaults to ``SIGKILL``

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)signal)r$   r>   killr@   )r   rq   s     r   rr   Container.kill	  s&     {{##DGGF#;;r    c                 d    U R                   R                  R                  " U R                  40 UD6$ )aL  
Get logs from this container. Similar to the ``docker logs`` command.

The ``stream`` parameter makes the ``logs`` function return a blocking
generator you can iterate over to retrieve log output as it happens.

Args:
    stdout (bool): Get ``STDOUT``. Default ``True``
    stderr (bool): Get ``STDERR``. Default ``True``
    stream (bool): Stream the response. Default ``False``
    timestamps (bool): Show timestamps. Default ``False``
    tail (str or int): Output specified number of lines at the end of
        logs. Either an integer of number of lines or the string
        ``all``. Default ``all``
    since (datetime, int, or float): Show logs since a given datetime,
        integer epoch (in seconds) or float (in nanoseconds)
    follow (bool): Follow log output. Default ``False``
    until (datetime, int, or float): Show logs that occurred before
        the given datetime, integer epoch (in seconds), or
        float (in nanoseconds)

Returns:
    (generator or str): Logs from the container.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   logsr@   rA   s     r   ru   Container.logs  s&    : {{##DGG6v66r    c                 `    U R                   R                  R                  U R                  5      $ )z
Pauses all processes within this container.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   pauser@   r   s    r   rx   Container.pause6  s!     {{$$TWW--r    c                 b    U R                   R                  R                  U R                  X5      $ )a_  
Insert a file or folder in this container using a tar archive as
source.

Args:
    path (str): Path inside the container where the file(s) will be
        extracted. Must exist.
    data (bytes or stream): tar data to be extracted

Returns:
    (bool): True if the call succeeds.

Raises:
    :py:class:`~docker.errors.APIError` If an error occurs.
)r$   r>   put_archiver@   )r   rm   datas      r   r{   Container.put_archive@  s#      {{**477D??r    c                 d    U R                   R                  R                  " U R                  40 UD6$ )a  
Remove this container. Similar to the ``docker rm`` command.

Args:
    v (bool): Remove the volumes associated with the container
    link (bool): Remove the specified link and not the underlying
        container
    force (bool): Force the removal of a running container (uses
        ``SIGKILL``)

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   remove_containerr@   rA   s     r   removeContainer.removeR  s&     {{//B6BBr    c                 b    U R                   R                  R                  U R                  U5      $ )z
Rename this container. Similar to the ``docker rename`` command.

Args:
    name (str): New name for the container

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   renamer@   )r   r   s     r   r   Container.renamec  s#     {{%%dggt44r    c                 b    U R                   R                  R                  U R                  X5      $ )z
Resize the tty session.

Args:
    height (int): Height of tty session
    width (int): Width of tty session

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   resizer@   )r   heightwidths      r   r   Container.resizep  s#     {{%%dggv==r    c                 d    U R                   R                  R                  " U R                  40 UD6$ )aG  
Restart this container. Similar to the ``docker restart`` command.

Args:
    timeout (int): Number of seconds to try to stop for before killing
        the container. Once killed it will then be restarted. Default
        is 10 seconds.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   restartr@   rA   s     r   r   Container.restart~  s&     {{&&tww9&99r    c                 d    U R                   R                  R                  " U R                  40 UD6$ )z
Start this container. Similar to the ``docker start`` command, but
doesn't support attach options.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   startr@   rA   s     r   r   Container.start  s&     {{$$TWW777r    c                 d    U R                   R                  R                  " U R                  40 UD6$ )a  
Stream statistics for this container. Similar to the
``docker stats`` command.

Args:
    decode (bool): If set to true, stream will be decoded into dicts
        on the fly. Only applicable if ``stream`` is True.
        False by default.
    stream (bool): If set to false, only the current stats will be
        returned instead of a stream. True by default.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   statsr@   rA   s     r   r   Container.stats  s&      {{$$TWW777r    c                 d    U R                   R                  R                  " U R                  40 UD6$ )a  
Stops a container. Similar to the ``docker stop`` command.

Args:
    timeout (int): Timeout in seconds to wait for the container to
        stop before sending a ``SIGKILL``. Default: 10

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   stopr@   rA   s     r   r   Container.stop  s&     {{##DGG6v66r    c                 d    U R                   R                  R                  " U R                  40 UD6$ )a   
Display the running processes of the container.

Args:
    ps_args (str): An optional arguments passed to ps (e.g. ``aux``)

Returns:
    (str): The output of the top

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   topr@   rA   s     r   r   Container.top  s&     {{""4775f55r    c                 `    U R                   R                  R                  U R                  5      $ )z
Unpause all processes within the container.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   unpauser@   r   s    r   r   Container.unpause  s!     {{&&tww//r    c                 d    U R                   R                  R                  " U R                  40 UD6$ )ag  
Update resource configuration of the containers.

Args:
    blkio_weight (int): Block IO (relative weight), between 10 and 1000
    cpu_period (int): Limit CPU CFS (Completely Fair Scheduler) period
    cpu_quota (int): Limit CPU CFS (Completely Fair Scheduler) quota
    cpu_shares (int): CPU shares (relative weight)
    cpuset_cpus (str): CPUs in which to allow execution
    cpuset_mems (str): MEMs in which to allow execution
    mem_limit (int or str): Memory limit
    mem_reservation (int or str): Memory soft limit
    memswap_limit (int or str): Total memory (memory + swap), -1 to
        disable swap
    kernel_memory (int or str): Kernel memory limit
    restart_policy (dict): Restart policy dictionary

Returns:
    (dict): Dictionary containing a ``Warnings`` key.

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   update_containerr@   rA   s     r   updateContainer.update  s&    2 {{//B6BBr    c                 d    U R                   R                  R                  " U R                  40 UD6$ )ak  
Block until the container stops, then return its exit code. Similar to
the ``docker wait`` command.

Args:
    timeout (int): Request timeout
    condition (str): Wait until a container state reaches the given
        condition, either ``not-running`` (default), ``next-exit``,
        or ``removed``

Returns:
    (dict): The API's response as a Python dictionary, including
        the container's exit code under the ``StatusCode`` attribute.

Raises:
    :py:class:`requests.exceptions.ReadTimeout`
        If the timeout is exceeded.
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   waitr@   rA   s     r   r   Container.wait  s&    * {{##DGG6v66r     )NN)TTFFF FFFNNFN)#__name__
__module____qualname____firstlineno____doc__propertyr   r(   r/   r6   r;   r?   rE   rK   rO   re   r   rh   rl   rr   ru   rx   r{   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__r   r    r   r   r      s     2 2 > >   # # F F94@ 22- HMAFEJ8
t !8 ;$ ,C"'"FH<7>.@$C"5>:	88$76 0C67r    r   c                       \ rS rSr\r  S	S jrS
S jrS r  SS jr	S
S jr
\R                  R                  \
l        Srg)ContainerCollectioni  Nc                    [        U[        5      (       a  UR                  nUR                  SS5      nUR                  SS5      nUR	                  SS5      n	U(       aG  U(       a@  [        U R                  R                  R                  S5      (       a  SUS'   O[        S	5      eUR	                  S
5      (       a!  UR	                  S5      (       a  [        S5      eUR	                  S5      (       a!  UR	                  S
5      (       d  [        S5      e U R                  " SXUS.UD6n
U
R                  5         U(       a  U
$ U
R                  S   S   S   nSnUS:X  d  US:X  a  U
R!                  X4SSS9nU
R#                  5       S   nUS:w  a(  SnUR	                  S5      (       d  U
R!                  SSS9nU(       a  U
R%                  5         US:w  a  ['        XX!U5      eU(       d  Uc  U$ SR)                  U Vs/ s H  oPM     sn5      $ ! [         a<    U R                  R                  R                  XS9  U R                  " SXUS.UD6n
 GN*f = fs  snf )a8  
Run a container. By default, it will wait for the container to finish
and return its logs, similar to ``docker run``.

If the ``detach`` argument is ``True``, it will start the container
and immediately return a :py:class:`Container` object, similar to
``docker run -d``.

Example:
    Run a container and get its output:

    >>> import docker
    >>> client = docker.from_env()
    >>> client.containers.run('alpine', 'echo hello world')
    b'hello world\n'

    Run a container and detach:

    >>> container = client.containers.run('bfirsh/reticulate-splines',
                                          detach=True)
    >>> container.logs()
    'Reticulating spline 1...\nReticulating spline 2...\n'

Args:
    image (str): The image to run.
    command (str or list): The command to run in the container.
    auto_remove (bool): enable auto-removal of the container on daemon
        side when the container's process exits.
    blkio_weight_device: Block IO weight (relative device weight) in
        the form of: ``[{"Path": "device_path", "Weight": weight}]``.
    blkio_weight: Block IO weight (relative weight), accepts a weight
        value between 10 and 1000.
    cap_add (list of str): Add kernel capabilities. For example,
        ``["SYS_ADMIN", "MKNOD"]``.
    cap_drop (list of str): Drop kernel capabilities.
    cgroup_parent (str): Override the default parent cgroup.
    cgroupns (str): Override the default cgroup namespace mode for the
        container. One of:
        - ``private`` the container runs in its own private cgroup
          namespace.
        - ``host`` use the host system's cgroup namespace.
    cpu_count (int): Number of usable CPUs (Windows only).
    cpu_percent (int): Usable percentage of the available CPUs
        (Windows only).
    cpu_period (int): The length of a CPU period in microseconds.
    cpu_quota (int): Microseconds of CPU time that the container can
        get in a CPU period.
    cpu_rt_period (int): Limit CPU real-time period in microseconds.
    cpu_rt_runtime (int): Limit CPU real-time runtime in microseconds.
    cpu_shares (int): CPU shares (relative weight).
    cpuset_cpus (str): CPUs in which to allow execution (``0-3``,
        ``0,1``).
    cpuset_mems (str): Memory nodes (MEMs) in which to allow execution
        (``0-3``, ``0,1``). Only effective on NUMA systems.
    detach (bool): Run container in the background and return a
        :py:class:`Container` object.
    device_cgroup_rules (:py:class:`list`): A list of cgroup rules to
        apply to the container.
    device_read_bps: Limit read rate (bytes per second) from a device
        in the form of: `[{"Path": "device_path", "Rate": rate}]`
    device_read_iops: Limit read rate (IO per second) from a device.
    device_write_bps: Limit write rate (bytes per second) from a
        device.
    device_write_iops: Limit write rate (IO per second) from a device.
    devices (:py:class:`list`): Expose host devices to the container,
        as a list of strings in the form
        ``<path_on_host>:<path_in_container>:<cgroup_permissions>``.

        For example, ``/dev/sda:/dev/xvda:rwm`` allows the container
        to have read-write access to the host's ``/dev/sda`` via a
        node named ``/dev/xvda`` inside the container.
    device_requests (:py:class:`list`): Expose host resources such as
        GPUs to the container, as a list of
        :py:class:`docker.types.DeviceRequest` instances.
    dns (:py:class:`list`): Set custom DNS servers.
    dns_opt (:py:class:`list`): Additional options to be added to the
        container's ``resolv.conf`` file.
    dns_search (:py:class:`list`): DNS search domains.
    domainname (str or list): Set custom DNS search domains.
    entrypoint (str or list): The entrypoint for the container.
    environment (dict or list): Environment variables to set inside
        the container, as a dictionary or a list of strings in the
        format ``["SOMEVARIABLE=xxx"]``.
    extra_hosts (dict): Additional hostnames to resolve inside the
        container, as a mapping of hostname to IP address.
    group_add (:py:class:`list`): List of additional group names and/or
        IDs that the container process will run as.
    healthcheck (dict): Specify a test to perform to check that the
        container is healthy. The dict takes the following keys:

        - test (:py:class:`list` or str): Test to perform to determine
            container health. Possible values:

            - Empty list: Inherit healthcheck from parent image
            - ``["NONE"]``: Disable healthcheck
            - ``["CMD", args...]``: exec arguments directly.
            - ``["CMD-SHELL", command]``: Run command in the system's
              default shell.

            If a string is provided, it will be used as a ``CMD-SHELL``
            command.
        - interval (int): The time to wait between checks in
          nanoseconds. It should be 0 or at least 1000000 (1 ms).
        - timeout (int): The time to wait before considering the check
          to have hung. It should be 0 or at least 1000000 (1 ms).
        - retries (int): The number of consecutive failures needed to
            consider a container as unhealthy.
        - start_period (int): Start period for the container to
            initialize before starting health-retries countdown in
            nanoseconds. It should be 0 or at least 1000000 (1 ms).
    hostname (str): Optional hostname for the container.
    init (bool): Run an init inside the container that forwards
        signals and reaps processes
    init_path (str): Path to the docker-init binary
    ipc_mode (str): Set the IPC mode for the container.
    isolation (str): Isolation technology to use. Default: `None`.
    kernel_memory (int or str): Kernel memory limit
    labels (dict or list): A dictionary of name-value labels (e.g.
        ``{"label1": "value1", "label2": "value2"}``) or a list of
        names of labels to set with empty values (e.g.
        ``["label1", "label2"]``)
    links (dict): Mapping of links using the
        ``{'container': 'alias'}`` format. The alias is optional.
        Containers declared in this dict will be linked to the new
        container using the provided alias. Default: ``None``.
    log_config (LogConfig): Logging configuration.
    lxc_conf (dict): LXC config.
    mac_address (str): MAC address to assign to the container.
    mem_limit (int or str): Memory limit. Accepts float values
        (which represent the memory limit of the created container in
        bytes) or a string with a units identification char
        (``100000b``, ``1000k``, ``128m``, ``1g``). If a string is
        specified without a units character, bytes are assumed as an
        intended unit.
    mem_reservation (int or str): Memory soft limit.
    mem_swappiness (int): Tune a container's memory swappiness
        behavior. Accepts number between 0 and 100.
    memswap_limit (str or int): Maximum amount of memory + swap a
        container is allowed to consume.
    mounts (:py:class:`list`): Specification for mounts to be added to
        the container. More powerful alternative to ``volumes``. Each
        item in the list is expected to be a
        :py:class:`docker.types.Mount` object.
    name (str): The name for this container.
    nano_cpus (int):  CPU quota in units of 1e-9 CPUs.
    network (str): Name of the network this container will be connected
        to at creation time. You can connect to additional networks
        using :py:meth:`Network.connect`. Incompatible with
        ``network_mode``.
    network_disabled (bool): Disable networking.
    network_mode (str): One of:

        - ``bridge`` Create a new network stack for the container on
          the bridge network.
        - ``none`` No networking for this container.
        - ``container:<name|id>`` Reuse another container's network
          stack.
        - ``host`` Use the host network stack.
          This mode is incompatible with ``ports``.

        Incompatible with ``network``.
    network_driver_opt (dict): A dictionary of options to provide
        to the network driver. Defaults to ``None``. Used in
        conjuction with ``network``. Incompatible
        with ``network_mode``.
    oom_kill_disable (bool): Whether to disable OOM killer.
    oom_score_adj (int): An integer value containing the score given
        to the container in order to tune OOM killer preferences.
    pid_mode (str): If set to ``host``, use the host PID namespace
        inside the container.
    pids_limit (int): Tune a container's pids limit. Set ``-1`` for
        unlimited.
    platform (str): Platform in the format ``os[/arch[/variant]]``.
        Only used if the method needs to pull the requested image.
    ports (dict): Ports to bind inside the container.

        The keys of the dictionary are the ports to bind inside the
        container, either as an integer or a string in the form
        ``port/protocol``, where the protocol is either ``tcp``,
        ``udp``, or ``sctp``.

        The values of the dictionary are the corresponding ports to
        open on the host, which can be either:

        - The port number, as an integer. For example,
          ``{'2222/tcp': 3333}`` will expose port 2222 inside the
          container as port 3333 on the host.
        - ``None``, to assign a random host port. For example,
          ``{'2222/tcp': None}``.
        - A tuple of ``(address, port)`` if you want to specify the
          host interface. For example,
          ``{'1111/tcp': ('127.0.0.1', 1111)}``.
        - A list of integers, if you want to bind multiple host ports
          to a single container port. For example,
          ``{'1111/tcp': [1234, 4567]}``.

        Incompatible with ``host`` network mode.
    privileged (bool): Give extended privileges to this container.
    publish_all_ports (bool): Publish all ports to the host.
    read_only (bool): Mount the container's root filesystem as read
        only.
    remove (bool): Remove the container when it has finished running.
        Default: ``False``.
    restart_policy (dict): Restart the container when it exits.
        Configured as a dictionary with keys:

        - ``Name`` One of ``on-failure``, or ``always``.
        - ``MaximumRetryCount`` Number of times to restart the
          container on failure.

        For example:
        ``{"Name": "on-failure", "MaximumRetryCount": 5}``

    runtime (str): Runtime to use with this container.
    security_opt (:py:class:`list`): A list of string values to
        customize labels for MLS systems, such as SELinux.
    shm_size (str or int): Size of /dev/shm (e.g. ``1G``).
    stdin_open (bool): Keep ``STDIN`` open even if not attached.
    stdout (bool): Return logs from ``STDOUT`` when ``detach=False``.
        Default: ``True``.
    stderr (bool): Return logs from ``STDERR`` when ``detach=False``.
        Default: ``False``.
    stop_signal (str): The stop signal to use to stop the container
        (e.g. ``SIGINT``).
    storage_opt (dict): Storage driver options per container as a
        key-value mapping.
    stream (bool): If true and ``detach`` is false, return a log
        generator instead of a string. Ignored if ``detach`` is true.
        Default: ``False``.
    sysctls (dict): Kernel parameters to set in the container.
    tmpfs (dict): Temporary filesystems to mount, as a dictionary
        mapping a path inside the container to options for that path.

        For example:

        .. code-block:: python

            {
                '/mnt/vol2': '',
                '/mnt/vol1': 'size=3G,uid=1000'
            }

    tty (bool): Allocate a pseudo-TTY.
    ulimits (:py:class:`list`): Ulimits to set inside the container,
        as a list of :py:class:`docker.types.Ulimit` instances.
    use_config_proxy (bool): If ``True``, and if the docker client
        configuration file (``~/.docker/config.json`` by default)
        contains a proxy configuration, the corresponding environment
        variables will be set in the container being built.
    user (str or int): Username or UID to run commands as inside the
        container.
    userns_mode (str): Sets the user namespace mode for the container
        when user namespace remapping option is enabled. Supported
        values are: ``host``
    uts_mode (str): Sets the UTS namespace mode for the container.
        Supported values are: ``host``
    version (str): The version of the API to use. Set to ``auto`` to
        automatically detect the server's version. Default: ``1.35``
    volume_driver (str): The name of a volume driver/plugin.
    volumes (dict or list): A dictionary to configure volumes mounted
        inside the container. The key is either the host path or a
        volume name, and the value is a dictionary with the keys:

        - ``bind`` The path to mount the volume inside the container
        - ``mode`` Either ``rw`` to mount the volume read/write, or
          ``ro`` to mount it read-only.

        For example:

        .. code-block:: python

            {'/home/user1/': {'bind': '/mnt/vol2', 'mode': 'rw'},
             '/var/www': {'bind': '/mnt/vol1', 'mode': 'ro'}}

        Or a list of strings which each one of its elements specifies a
        mount volume.

        For example:

        .. code-block:: python

            ['/home/user1/:/mnt/vol2','/var/www:/mnt/vol1']

    volumes_from (:py:class:`list`): List of container names or IDs to
        get volumes from.
    working_dir (str): Path to the working directory.

Returns:
    The container logs, either ``STDOUT``, ``STDERR``, or both,
    depending on the value of the ``stdout`` and ``stderr`` arguments.

    ``STDOUT`` and ``STDERR`` may be read only if either ``json-file``
    or ``journald`` logging driver used. Thus, if you are using none of
    these drivers, a ``None`` object is returned instead. See the
    `Engine API documentation
    <https://docs.docker.com/engine/api/v1.30/#operation/ContainerLogs/>`_
    for full details.

    If ``detach`` is ``True``, a :py:class:`Container` object is
    returned instead.

Raises:
    :py:class:`docker.errors.ContainerError`
        If the container exits with a non-zero exit code and
        ``detach`` is ``False``.
    :py:class:`docker.errors.ImageNotFound`
        If the specified image does not exist.
    :py:class:`docker.errors.APIError`
        If the server returns an error.
r[   FrZ   platformNz1.25Tauto_removezQThe options 'detach' and 'remove' cannot be used together in api versions < 1.25.networknetwork_modezBThe options "network" and "network_mode" can not be used together.network_driver_optzCThe options "network_driver_opt" can not be used without "network".)r(   commandrZ   )r   r   	LogConfigTypez	json-filejournald)rR   rS   r[   follow
StatusCoder   )rR   rS   r    r   )r4   r   r@   popr   r   r$   r>   _versionRuntimeErrorcreater	   r%   pullr   r   ru   r   r   r   join)r   r(   r   rR   rS   r   rB   r[   rZ   r   	containerlogging_driveroutexit_statuslines                  r   runContainerCollection.run  s\   p	 eU##HHEHe,He,::j$/f4;;??33V<<(,}%" $N O O ::i  VZZ%?%? 
 ::*++FJJy4I4I% 
	= =%+1=5;=I 	"6{CFK[(Nj,H..T$ ! C  nn&|4!C::m,,nnE$n?!   s 	
!"cdTc"2
 	
?  	=KK##E#= =%+1=5;=I	=@ #s   H =IAIIc                 $   [        U[        5      (       a  UR                  nXS'   X#S'   U R                  R                  R
                  US'   [        U5      nU R                  R                  R                  " S0 UD6nU R                  US   5      $ )a  
Create a container without starting it. Similar to ``docker create``.

Takes the same arguments as :py:meth:`run`, except for ``stdout``,
``stderr``, and ``remove``.

Returns:
    A :py:class:`Container` object.

Raises:
    :py:class:`docker.errors.ImageNotFound`
        If the specified image does not exist.
    :py:class:`docker.errors.APIError`
        If the server returns an error.
r(   r   versionrJ   r   )	r4   r   r@   r$   r>   r   _create_container_argscreate_containerr   )r   r(   r   rB   create_kwargsrL   s         r   r   ContainerCollection.create  sy      eU##HHEw#y KKOO44y.v6{{//@-@xxT
##r    c                 n    U R                   R                  R                  U5      nU R                  U5      $ )a+  
Get a container by name or ID.

Args:
    container_id (str): Container name or ID.

Returns:
    A :py:class:`Container` object.

Raises:
    :py:class:`docker.errors.NotFound`
        If the container does not exist.
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)r$   r>   inspect_containerprepare_model)r   container_idrL   s      r   r   ContainerCollection.get  s-      {{00>!!$''r    c                 :   U R                   R                  R                  XX4US9nU(       a!  U V	s/ s H  oR                  U	5      PM     sn	$ / n
U H'  n	 U
R	                  U R                  U	S   5      5        M)     U
$ s  sn	f ! [         a    U(       d  e  MG  f = f)a  
List containers. Similar to the ``docker ps`` command.

Args:
    all (bool): Show all containers. Only running containers are shown
        by default
    since (str): Show only containers created since Id or Name, include
        non-running ones
    before (str): Show only container created before Id or Name,
        include non-running ones
    limit (int): Show `limit` last created containers, include
        non-running ones
    filters (dict): Filters to be processed on the image list.
        Available filters:

        - `exited` (int): Only containers with specified exit code
        - `status` (str): One of ``restarting``, ``running``,
            ``paused``, ``exited``
        - `label` (str|list): format either ``"key"``, ``"key=value"``
            or a list of such.
        - `id` (str): The id of the container.
        - `name` (str): The name of the container.
        - `ancestor` (str): Filter by container ancestor. Format of
            ``<image-name>[:tag]``, ``<image-id>``, or
            ``<image@digest>``.
        - `before` (str): Only containers created before a particular
            container. Give the container name or id.
        - `since` (str): Only containers created after a particular
            container. Give container name or id.

        A comprehensive list can be found in the documentation for
        `docker ps
        <https://docs.docker.com/engine/reference/commandline/ps>`_.

    sparse (bool): Do not inspect containers. Returns partial
        information, but guaranteed not to block. Use
        :py:meth:`Container.reload` on resulting objects to retrieve
        all attributes. Default: ``False``
    ignore_removed (bool): Ignore failures due to missing containers
        when attempting to inspect containers from the original list.
        Set to ``True`` if race conditions are likely. Has no effect
        if ``sparse=True``. Default: ``False``

Returns:
    (list of :py:class:`Container`)

Raises:
    :py:class:`docker.errors.APIError`
        If the server returns an error.
)allbeforefilterslimitsincerJ   )r$   r>   
containersr   appendr   r
   )r   r   r   r   r   r   sparseignore_removedrL   rr   s              r   listContainerCollection.list  s    h {{))c2905 * 7 3784a&&q)488J%%dhhqw&78   9   ) *s   A?#BBBc                 H    U R                   R                  R                  US9$ )N)r   )r$   r>   prune_containers)r   r   s     r   pruneContainerCollection.prune  s    {{///@@r    r   )NTFFr   )FNNNFF)r   r   r   r   r   modelr   r   r   r   r   r   r   r   r   r   r    r   r   r     sH    E;@u
n$2(& JN*/BHA..66EMr    r   )r   rZ   
domainname
entrypointrX   healthcheckhostnamer(   r/   mac_addressr   network_disabledr   
stdin_openstop_signalrU   use_config_proxyrW   working_dir)?r   blkio_weight_deviceblkio_weightcap_addcap_dropcgroup_parentcgroupns	cpu_countcpu_percent
cpu_period	cpu_quota
cpu_sharescpuset_cpuscpuset_memscpu_rt_periodcpu_rt_runtimedevice_cgroup_rulesdevice_read_bpsdevice_read_iopsdevice_write_bpsdevice_write_iopsdevicesdevice_requestsdns_opt
dns_searchdnsextra_hosts	group_addinit	init_pathipc_mode	isolationkernel_memorylinks
log_configlxc_conf	mem_limitmem_reservationmem_swappinessmemswap_limitmounts	nano_cpusr   oom_kill_disableoom_score_adjpid_mode
pids_limitrV   publish_all_ports	read_onlyrestart_policysecurity_optshm_sizestorage_optsysctlstmpfsulimitsuserns_modeuts_moder   volume_drivervolumes_fromruntimec           	         0 n[         R                   " U 5       H"  nU[        ;   d  M  U R                  U5      X'   M$     0 n[         R                   " U 5       H"  nU[        ;   d  M  U R                  U5      X2'   M$     U R                  S0 5      nU(       a  XCS'   U R                  S0 5      nU(       a  XSS'   U R                  SS5      nU R                  SS5      nU(       a  U(       a  SU0OSnXh0US	'   XcS
'   U (       a  [	        SU 5      e[        S0 UD6US'   US   R                  S5      n	U	(       aF  [        U	R                  5       5       V
s/ s H  n
[        U
R                  SS5      5      PM      sn
US'   U(       ah  [        U[        5      (       a4  UR                  5        Vs/ s H  oR                  S5      PM     snUS'   U$ U Vs/ s H  n[        U5      PM     snUS'   U$ s  sn
f s  snf s  snf )zC
Convert arguments to create() to arguments to create_container().
r;   port_bindingsvolumesbindsr   Nr   
driver_optnetworking_configr   r   host_configPortBindingsr   r   bindr   )copyRUN_CREATE_KWARGSr   RUN_HOST_CONFIG_KWARGSr   r   r   sortedkeystupler&   r4   r5   values_host_volume_from_bind)rB   r   keyhost_config_kwargsr;   r-  r   r   network_configurationr,  pvs               r   r   r   O  s   
 Myy ##!'CM ! yy ((&,jjo# !
 JJw#E.3?+jjB'G&-7#jjD)G$8$?! "./A B'+ 	 /6-M)*-4>* ,UF;;#-#C0B#CM-  "-044^DM ,2-2D2D2F+G"I+Ga #(Q"8+G"Iggt$$'.~~'7('7!f'7(M)$  4;(3:a&q)7(M)$ "I((s   %G,)G1G6c                    [         R                  " U 5      u  pUR                  SS5      n[        U5      S:X  d	  US   S;   a  XS   -   $ US   R	                  S5      (       d  US   R	                  S5      (       a  US   S S $ US   $ )Nr#   r   )rorwr   z:roz:rw)ntpath
splitdriver&   lenendswith)r3  driverestbitss       r   r;  r;    s    ##D)KE::c1D
4yA~aL0Aw	a		%	 	 DG$4$4U$;$;Aws|Awr    ra   zexit_code,output)r4  rE  collectionsr   r>   r   	constantsr   errorsr   r   r	   r
   r   typesr   utilsr   r%   r   resourcer   r   r   r   r5  r6  r   r;  ra   r   r    r   <module>rR     s{      "  /     'q7 q7hl7* l7` .@ F6r &89
r    