You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/concepts/services.md
+44-25Lines changed: 44 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -597,15 +597,12 @@ resources:
597
597
598
598
### Working directory
599
599
600
-
If `working_dir` is not specified, it defaults to `/workflow`.
600
+
If `working_dir` is not specified, it defaults to the working directory set in the Docker image. For example, the [default image](#default-image) uses `/dstack/run` as its working directory.
601
601
602
-
!!! info "No commands"
603
-
If you’re using a custom `image` without `commands`, then `working_dir` is taken from `image`.
602
+
If the Docker image does not have a working directory set, `dstack` uses `/` as the `working_dir`.
604
603
605
604
The `working_dir` must be an absolute path. The tilde (`~`) is supported (e.g., `~/my-working-dir`).
606
605
607
-
<!-- TODO: In a future version, the default working directory will be taken from `image`. -->
608
-
609
606
<!-- TODO: Elaborate on `entrypoint` -->
610
607
611
608
### Files
@@ -621,7 +618,7 @@ type: service
621
618
name: llama-2-7b-service
622
619
623
620
files:
624
-
- .:examples # Maps the directory where`.dstack.yml` to `/workflow/examples`
621
+
- .:examples # Maps the directory with`.dstack.yml` to `<working dir>/examples`
625
622
- ~/.ssh/id_rsa:/root/.ssh/id_rsa # Maps `~/.ssh/id_rsa` to `/root/.ssh/id_rsa`
626
623
627
624
python: 3.12
@@ -640,11 +637,10 @@ resources:
640
637
641
638
</div>
642
639
643
-
Each entry maps a local directory or file to a path inside the container. Both local and container paths can be relative or absolute.
644
-
645
-
If the local path is relative, it’s resolved relative to the configuration file. If the container path is relative, it’s resolved relative to `/workflow`.
640
+
If the local path is relative, it’s resolved relative to the configuration file.
641
+
If the container path is relative, it’s resolved relative to the [working directory](#working-directory).
646
642
647
-
The container path is optional. If not specified, it will be automatically calculated.
643
+
The container path is optional. If not specified, it will be automatically calculated:
648
644
649
645
<!-- TODO: Add a more relevant example -->
650
646
@@ -655,7 +651,7 @@ type: service
655
651
name: llama-2-7b-service
656
652
657
653
files:
658
-
- ../examples # Maps `examples` (the parent directory of `.dstack.yml`) to `/workflow/examples`
654
+
- ../examples # Maps the parent directory of `.dstack.yml` to `<working dir>/../examples`
659
655
- ~/.ssh/id_rsa # Maps `~/.ssh/id_rsa` to `/root/.ssh/id_rsa`
660
656
661
657
python: 3.12
@@ -681,9 +677,9 @@ resources:
681
677
682
678
### Repos
683
679
684
-
Sometimes, you may want to mount an entire Git repo inside the container.
680
+
Sometimes, you may want to clone an entire Git repo inside the container.
685
681
686
-
Imagine you have a cloned Git repo containing an `examples` subdirectory with a `.dstack.yml` file:
682
+
Imagine you have a Git repo (clonned locally) containing an `examples` subdirectory with a `.dstack.yml` file:
687
683
688
684
<!-- TODO: Add a more relevant example -->
689
685
@@ -694,8 +690,7 @@ type: service
694
690
name: llama-2-7b-service
695
691
696
692
repos:
697
-
# Mounts the parent directory of `examples` (must be a Git repo)
698
-
# to `/workflow` (the default working directory)
693
+
# Clones the repo from the parent directory (`examples/..`) to `<working dir>`
699
694
- ..
700
695
701
696
python: 3.12
@@ -714,12 +709,12 @@ resources:
714
709
715
710
</div>
716
711
717
-
When you run it, `dstack` fetches the repo on the instance, applies your local changes, and mounts it—so the container matches your local repo.
712
+
When you run it, `dstack` clones the repo on the instance, applies your local changes, and mounts it—so the container matches your local repo.
718
713
719
714
The local path can be either relative to the configuration file or absolute.
720
715
721
716
??? info "Repo directory"
722
-
By default, `dstack` mounts the repo to `/workflow` (the default working directory).
717
+
By default, `dstack` clones the repo to the [working directory](#working-directory).
723
718
724
719
<!-- TODO: In a future version, the default working directory will come from the image, so this should be revisited. -->
725
720
@@ -732,8 +727,7 @@ The local path can be either relative to the configuration file or absolute.
732
727
name: llama-2-7b-service
733
728
734
729
repos:
735
-
# Mounts the parent directory of `examples` (must be a Git repo)
736
-
# to `/my-repo`
730
+
# Clones the repo in the parent directory (`examples/..`) to `/my-repo`
737
731
- ..:/my-repo
738
732
739
733
python: 3.12
@@ -752,16 +746,41 @@ The local path can be either relative to the configuration file or absolute.
752
746
753
747
</div>
754
748
755
-
If the path is relative, it is resolved against `working_dir`.
749
+
> If the repo directory is relative, it is resolved against [working directory](#working-directory).
750
+
751
+
If the repo directory is not empty, the run will fail with a runner error.
752
+
To override this behavior, you can set `if_exists` to `skip`:
0 commit comments