How to use the podman.libs.containers.Container function in podman

To help you get started, we’ve selected a few podman examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github containers / python-podman / podman / libs / containers.py View on Github external
def get_by_context(self, all=True, latest=False, args=[]):
        """Get containers ids or names depending on all, latest, or a list of
        container names"""
        with self._client() as podman:
            results = podman.GetContainersByContext(all, latest, args)
        for cntr in results['containers']:
            yield Container(self._client, cntr['id'], cntr, refresh=False)
github containers / python-podman / podman / libs / containers.py View on Github external
def get(self, id_):
        """Retrieve container details from store."""
        with self._client() as podman:
            cntr = podman.GetContainer(id_)
        return Container(self._client, cntr['container']['id'],
                         cntr['container'])
github containers / python-podman / podman / libs / images.py View on Github external
config = ConfigDict(image_id=self._id, **kwargs)
        config["command"] = details.config.get("cmd")
        config["env"] = self._split_token(details.config.get("env"))
        config["image"] = copy.deepcopy(details.repotags[0])
        config["labels"] = copy.deepcopy(details.labels)
        # TODO: Are these settings still required?
        config["net_mode"] = "bridge"
        config["network"] = "bridge"
        config["args"] = flatten([config["image"], config["command"]])

        logging.debug("Image %s: create config: %s", self._id, config)
        with self._client() as podman:
            id_ = podman.CreateContainer(config)["container"]
            cntr = podman.GetContainer(id_)
        return Container(self._client, id_, cntr["container"])
github containers / python-podman / podman / libs / containers.py View on Github external
def get_by_status(self, status):
        """Get containers by status"""
        with self._client() as podman:
            results = podman.GetContainersByStatus(status)
        for cntr in results['containers']:
            yield Container(self._client, cntr['id'], cntr, refresh=False)
github containers / python-podman / podman / libs / containers.py View on Github external
def __init__(self, client, ident, data, refresh=True):
        """Construct Container Model."""
        super(Container, self).__init__(data)
        self._client = client
        self._id = ident

        if refresh:
            with client() as podman:
                self._refresh(podman)
        else:
            for k, v in self.data.items():
                setattr(self, k, v)
            if 'containerrunning' in self.data:
                setattr(self, 'running', self.data['containerrunning'])
                self.data['running'] = self.data['containerrunning']

        assert self._id == data['id'],\
            'Requested container id({}) does not match store id({})'.format(
                self._id, data['id']
github containers / python-podman / podman / libs / containers.py View on Github external
def list(self):
        """List of containers in the container store."""
        with self._client() as podman:
            results = podman.ListContainers()
        for cntr in results['containers']:
            yield Container(self._client, cntr['id'], cntr, refresh=False)