Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/dstack/_internal/core/compatibility/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def get_run_spec_excludes(run_spec: RunSpec) -> Optional[Dict]:
configuration_excludes["rate_limits"] = True
if configuration.shell is None:
configuration_excludes["shell"] = True
if configuration.docker is None:
configuration_excludes["docker"] = True
if configuration.priority is None:
configuration_excludes["priority"] = True
if configuration.startup_order is None:
Expand Down
24 changes: 22 additions & 2 deletions src/dstack/_internal/core/models/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,14 @@ class BaseRunConfiguration(CoreModel):
] = None
python: Annotated[
Optional[PythonVersion],
Field(description="The major version of Python. Mutually exclusive with `image`"),
Field(
description="The major version of Python. Mutually exclusive with `image` and `docker`"
),
] = None
nvcc: Annotated[
Optional[bool],
Field(
description="Use image with NVIDIA CUDA Compiler (NVCC) included. Mutually exclusive with `image`"
description="Use image with NVIDIA CUDA Compiler (NVCC) included. Mutually exclusive with `image` and `docker`"
),
] = None
single_branch: Annotated[
Expand Down Expand Up @@ -244,6 +246,12 @@ class BaseRunConfiguration(CoreModel):
volumes: Annotated[
List[Union[MountPoint, str]], Field(description="The volumes mount points")
] = []
docker: Annotated[
Optional[bool],
Field(
description="Use Docker inside the container. Mutually exclusive with `image`, `python`, and `nvcc`. Overrides `privileged`"
),
] = None
# deprecated since 0.18.31; task, service -- no effect; dev-environment -- executed right before `init`
setup: CommandsList = []

Expand All @@ -259,6 +267,18 @@ def convert_python(cls, v, values) -> Optional[PythonVersion]:
return PythonVersion(v)
return v

@validator("docker", pre=True, always=True)
def _docker(cls, v, values) -> Optional[bool]:
if v is True and values.get("image"):
raise KeyError("`image` and `docker` are mutually exclusive fields")
if v is True and values.get("python"):
raise KeyError("`python` and `docker` are mutually exclusive fields")
if v is True and values.get("nvcc"):
raise KeyError("`nvcc` and `docker` are mutually exclusive fields")
# Ideally, we'd like to also prohibit privileged=False when docker=True,
# but it's not possible to do so without breaking backwards compatibility.
return v

@validator("volumes", each_item=True)
def convert_volumes(cls, v) -> MountPoint:
if isinstance(v, str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ async def _commands(self) -> List[str]:
return result

def _dstack_image_commands(self) -> List[str]:
if self.run_spec.configuration.docker is True:
return ["start-dockerd"]
if (
self.run_spec.configuration.image is not None
or self.run_spec.configuration.entrypoint is not None
Expand Down Expand Up @@ -201,7 +203,9 @@ def _home_dir(self) -> Optional[str]:
return self.run_spec.configuration.home_dir

def _image_name(self) -> str:
if self.run_spec.configuration.image is not None:
if self.run_spec.configuration.docker is True:
return settings.DSTACK_DIND_IMAGE
elif self.run_spec.configuration.image is not None:
return self.run_spec.configuration.image
return get_default_image(nvcc=bool(self.run_spec.configuration.nvcc))

Expand All @@ -215,6 +219,8 @@ async def _user(self) -> Optional[UnixUser]:
return UnixUser.parse(user)

def _privileged(self) -> bool:
if self.run_spec.configuration.docker is True:
return True
return self.run_spec.configuration.privileged

def _single_branch(self) -> bool:
Expand Down
1 change: 1 addition & 0 deletions src/dstack/_internal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
DSTACK_BASE_IMAGE_UBUNTU_VERSION = os.getenv(
"DSTACK_BASE_IMAGE_UBUNTU_VERSION", version.base_image_ubuntu_version
)
DSTACK_DIND_IMAGE = os.getenv("DSTACK_DIND_IMAGE", "dstackai/dind")


class FeatureFlags:
Expand Down
Loading
Loading