class DockerException(Exception):
              """Base exception for all docker-py exceptions."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
                  self.message = message
          
          class APIError(DockerException):
              """Raised when the Docker API returns an error."""
          
              def __init__(self, response, explanation=None):
                  """
                  :param response: The response object from the Docker API.
                  :type response: requests.Response
                  :param explanation: An optional explanation of the error.
                  :type explanation: str
                  """
                  super().__init__(self._format_error_message(response, explanation))
                  self.response = response
                  self.explanation = explanation
          
              def _format_error_message(self, response, explanation):
                  """Formats the error message from the Docker API response."""
                  message = "API error: {0}".format(response.text)
                  if explanation:
                      message += "\n{0}".format(explanation)
                  return message
          
          class NotFound(DockerException):
              """Raised when a resource is not found."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class InvalidVersion(DockerException):
              """Raised when the Docker API version is not supported."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class BuildError(DockerException):
              """Raised when a Docker build fails."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class ContainerError(DockerException):
              """Raised when a Docker container exits with a non-zero exit code."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class ImageNotFound(NotFound):
              """Raised when an image is not found."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class ImagePullError(DockerException):
              """Raised when an image pull fails."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class InvalidArgument(DockerException):
              """Raised when an invalid argument is passed to a Docker API call."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class ClientError(DockerException):
              """Raised when the Docker client encounters an error."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class TLSParameterError(DockerException):
              """Raised when an invalid TLS parameter is passed to a Docker API call."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class DockerClientException(DockerException):
              """Raised when the Docker client encounters an error."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class InvalidRepository(DockerException):
              """Raised when an invalid repository name is passed to a Docker API call."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class InvalidTag(DockerException):
              """Raised when an invalid tag is passed to a Docker API call."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class InvalidRegistry(DockerException):
              """Raised when an invalid registry is passed to a Docker API call."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class InvalidHost(DockerException):
              """Raised when an invalid host is passed to a Docker API call."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class ServerError(DockerException):
              """Raised when the Docker server encounters an error."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class NullResource(DockerException):
              """Raised when a resource is not found."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class VersionError(DockerException):
              """Raised when the Docker API version is not supported."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class TimeoutError(DockerException):
              """Raised when a Docker API call times out."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)
          
          class ConnectionError(DockerException):
              """Raised when the Docker client cannot connect to the Docker server."""
          
              def __init__(self, message, *args, **kwargs):
                  super().__init__(message, *args, **kwargs)