File: //usr/lib/python3/dist-packages/docker/models/__pycache__/containers.cpython-310.pyc
o
��/aR� � @ s� d dl Z d dlZd dlmZ ddlmZ ddlmZ ddlm Z m
Z
mZmZm
Z
ddlmZ ddlmZ d d
lmZ d dlmZmZ G dd
� d
e�ZG dd� de�Zg d�Zg d�Zdd� Zdd� Zedd�ZdS )� N)�
namedtuple� )� APIClient)�DEFAULT_DATA_CHUNK_SIZE)�ContainerError�DockerException�
ImageNotFound�NotFound�create_unexpected_kwargs_error)�
HostConfig)�version_gte� )�Image)�
Collection�Modelc @ s e Zd ZdZedd� �Zedd� �Zedd� �Zedd � �Zed
d� �Z dd
� Z
dd� Zd<dd�Zdd� Z
d=dd�Zefdd�Zedfdd�Zd>dd�Zd d!� Zd"d#� Zd$d%� Zd&d'� Zd(d)� Zd*d+� Zd,d-� Zd.d/� Zd0d1� Zd2d3� Zd4d5� Zd6d7� Zd8d9� Zd:d;� Z dS )?� ContaineraI 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 C s$ | j �d�dur| j d �d�S dS )z,
The name of the container.
�NameN�/)�attrs�get�lstrip��self� r �:/usr/lib/python3/dist-packages/docker/models/containers.py�name s �zContainer.namec C s8 | j �d| j d �}|du rdS | jj�|�d�d �S )z-
The image of the container.
�ImageIDr N�:r
)r r �client�images�split)r �image_idr r r �image s zContainer.imagec C s2 z
| j d �d�}|pi W S ty td��w )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 �resultr r r �labels* s
��zContainer.labelsc C s( t | jd t�r| jd d S | jd S )zW
The status of the container. For example, ``running``, or ``exited``.
�State�Status)�
isinstancer �dictr r r r �status8 s
zContainer.statusc C s | j �di ��di �S )zG
The ports that the container exposes as a dictionary.
�NetworkSettings�Ports)r r r r r r �portsA s zContainer.portsc K � | j jj| jfi |��S )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 �kwargsr r r r2 H s zContainer.attachc K r0 )a�
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 r1 �
attach_socketr3 r4 r r r r6 b � zContainer.attach_socketNc K s0 | j jj| jf||d�|��}| j j�|d �S )a�
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 r1 �commitr3 r r )r r8 r9 r5 �respr r r r; r s �zContainer.commitc C � | j j�| j�S )z�
Inspect changes on a container's filesystem.
Returns:
(str)
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
)r r1 �diffr3 r r r r r>