MCPcopy Index your code
hub / github.com/docker/docker-py / create

Method create

docker/models/containers.py:913–936  ·  view source on GitHub ↗

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.

(self, image, command=None, **kwargs)

Source from the content-addressed store, hash-verified

911 return b''.join(out)
912
913 def create(self, image, command=None, **kwargs):
914 """
915 Create a container without starting it. Similar to ``docker create``.
916
917 Takes the same arguments as :py:meth:`run`, except for ``stdout``,
918 ``stderr``, and ``remove``.
919
920 Returns:
921 A :py:class:`Container` object.
922
923 Raises:
924 :py:class:`docker.errors.ImageNotFound`
925 If the specified image does not exist.
926 :py:class:`docker.errors.APIError`
927 If the server returns an error.
928 """
929 if isinstance(image, Image):
930 image = image.id
931 kwargs['image'] = image
932 kwargs['command'] = command
933 kwargs['version'] = self.client.api._version
934 create_kwargs = _create_container_args(kwargs)
935 resp = self.client.api.create_container(**create_kwargs)
936 return self.get(resp['Id'])
937
938 def get(self, container_id):
939 """

Callers 1

runMethod · 0.95

Calls 3

getMethod · 0.95
_create_container_argsFunction · 0.85
create_containerMethod · 0.80

Tested by

no test coverage detected