An OCI-compatible container, also known as a Docker container.
| 1837 | |
| 1838 | @typecheck |
| 1839 | class 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, |
no outgoing calls
no test coverage detected