Skip to content

Commit f44a970

Browse files
committed
fix: don't mark volume as external in bind-mount workspaces
The `devcontainer-volume` volume alias must be `external: false` for bind-mount workspaces, otherwise Docker Compose errors, complaining that it doesn't exist (even though it's not referenced).
1 parent 5bbf23b commit f44a970

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

.devcontainer/docker-compose.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ services:
2424
- ${WORKSPACE_SOURCE:?}:${WORKSPACE_TARGET:?}
2525

2626
volumes:
27-
# $WORKSPACE_SOURCE is "devcontainer-volume" when the workspace is in a volume
27+
# $WORKSPACE_SOURCE is "devcontainer-volume" when the workspace is in a
28+
# volume, and devcontainer-volume is an alias for the actual external volume.
29+
# In bind-mount workspaces, it's an empty, unused volume created by compose.
2830
devcontainer-volume:
29-
name: ${WORKSPACE_CONTAINER_VOLUME_SOURCE}
30-
external: true
31+
name: ${WORKSPACE_CONTAINER_VOLUME_SOURCE:-not-used-in-bind-mount-workspace}
32+
external: ${WORKSPACE_IS_CONTAINER_VOLUME:?}

.devcontainer/gen-docker-compose-workspace-env.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ and including references to the envars it generates in your docker-compose.yaml:
128128
129129
volumes:
130130
devcontainer-volume:
131-
name: ${WORKSPACE_CONTAINER_VOLUME_SOURCE:?-devcontainer-volume_not-used-in-bind-mount-workspace}
132-
external: ${WORKSPACE_IS_CONTAINER_VOLUME}
131+
name: ${WORKSPACE_CONTAINER_VOLUME_SOURCE:-not-used-in-bind-mount-workspace}
132+
external: ${WORKSPACE_IS_CONTAINER_VOLUME:?}
133133
EOF
134134
)"
135135

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ The key parts are:
5959
```yaml
6060
volumes:
6161
devcontainer-volume:
62-
name: ${WORKSPACE_CONTAINER_VOLUME_SOURCE}
63-
external: true
62+
name: ${WORKSPACE_CONTAINER_VOLUME_SOURCE:-not-used-in-bind-mount-workspace}
63+
external: ${WORKSPACE_IS_CONTAINER_VOLUME:?}
6464
```
6565
6666
## Compatibility

0 commit comments

Comments
 (0)