MCPcopy Create free account
hub / github.com/dagger/dagger / Container

Class Container

sdk/python/src/dagger/client/gen.py:1839–4020  ·  view source on GitHub ↗

An OCI-compatible container, also known as a Docker container.

Source from the content-addressed store, hash-verified

1837
1838@typecheck
1839class Container(Type):
1840 """An OCI-compatible container, also known as a Docker container."""
1841
1842 def as_service(
1843 self,
1844 *,
1845 args: list[str] | None = None,
1846 use_entrypoint: bool | None = False,
1847 experimental_privileged_nesting: bool | None = False,
1848 insecure_root_capabilities: bool | None = False,
1849 expand: bool | None = False,
1850 no_init: bool | None = False,
1851 ) -> "Service":
1852 """Turn the container into a Service.
1853
1854 Be sure to set any exposed ports before this conversion.
1855
1856 Parameters
1857 ----------
1858 args:
1859 Command to run instead of the container's default command (e.g.,
1860 ["go", "run", "main.go"]).
1861 If empty, the container's default command is used.
1862 use_entrypoint:
1863 If the container has an entrypoint, prepend it to the args.
1864 experimental_privileged_nesting:
1865 Provides Dagger access to the executed command.
1866 insecure_root_capabilities:
1867 Execute the command with all root capabilities. This is similar to
1868 running a command with "sudo" or executing "docker run" with the "
1869 --privileged" flag. Containerization does not provide any security
1870 guarantees when using this option. It should only be used when
1871 absolutely necessary and only with trusted commands.
1872 expand:
1873 Replace "${VAR}" or "$VAR" in the args according to the current
1874 environment variables defined in the container (e.g. "/$VAR/foo").
1875 no_init:
1876 If set, skip the automatic init process injected into containers
1877 by default.
1878 This should only be used if the user requires that their exec
1879 process be the pid 1 process in the container. Otherwise it may
1880 result in unexpected behavior.
1881 """
1882 _args = [
1883 Arg("args", [] if args is None else args, []),
1884 Arg("useEntrypoint", use_entrypoint, False),
1885 Arg(
1886 "experimentalPrivilegedNesting", experimental_privileged_nesting, False
1887 ),
1888 Arg("insecureRootCapabilities", insecure_root_capabilities, False),
1889 Arg("expand", expand, False),
1890 Arg("noInit", no_init, False),
1891 ]
1892 _ctx = self._select("asService", _args)
1893 return Service(_ctx)
1894
1895 def as_tarball(
1896 self,

Callers 15

containerMethod · 0.70
as_containerMethod · 0.70
experimental_with_gpuMethod · 0.70
from_Method · 0.70
import_Method · 0.70
terminalMethod · 0.70
with_annotationMethod · 0.70
with_default_argsMethod · 0.70
with_directoryMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected