devcontainers / devcontainers/cli

Incorrect field used as mapping key for deserialization of 'mounts' in devcontainer.json

Đang mở
#824 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
TypeScript
Star
3k
Fork
457
Merge trung bình
13 giờ 17 phút
Pull request đã merge (30 ngày)
6

Mô tả

If specifying mounts in `devcontainer.json` and trying to mount the same volume in different locations, you get a deserialization error.
```
[2024-05-08T20:39:45.846Z] parsing /tmp/devcontainercli-root/docker-compose/docker-compose.devcontainer.containerFeatures-1715200785780-516d96c0-3c67-479f-b191-c3c3d323c3c3.yml: yaml: unmarshal errors:
line 28: mapping key "build-obj" already defined at line 26
```

However this works without problems if you specify the volumes in `docker-compose.yml`.
```
volumes:
- build-obj:/workspace/src/a/build
- build-obj:/workspace/src/b/build
```

If a unique key is needed, the _target_ and not the source of the mount should be used.

Log fragment
```
[2024-05-08T20:39:45.780Z] Docker Compose override file for creating container:
version: '3.8'

services:
'dev-build':
entrypoint: ["/bin/sh", "-c", "echo Container started\n
trap \"exit 0\" 15\n
\n
exec \"$$@\"\n
while sleep 1 & wait $$!; do :; done", "-"]
command: ["/usr/bin/sleep","infinity"]
labels:
- 'devcontainer.local_folder=/root/workspace/dev-container'
- 'devcontainer.config_file=/root/workspace/dev-container/.devcontainer/devcontainer.json'
volumes:
- /root/workspace/dev-container:/workspace
- build-obj:/workspace/src/a/build
- build-obj:/workspace/src/b/build
- vscode:/vscode
volumes:

build-obj:

build-obj:

vscode:
external: true
[2024-05-08T20:39:45.780Z] Writing docker-compose.devcontainer.containerFeatures-1715200785780-516d96c0-3c67-479f-b191-c3c3d323c3c3.yml to /tmp/devcontainercli-root/docker-compose
[2024-05-08T20:39:45.781Z] Start: Run: /usr/bin/docker-compose --project-name devcontainer -f /root/workspace/dev-container/.devcontainer/docker-compose.yml -f /tmp/devcontainercli-root/docker-compose/docker-compose.devcontainer.build-1715200784920.yml -f /tmp/devcontainercli-root/docker-compose/docker-compose.devcontainer.containerFeatures-1715200785780-516d96c0-3c67-479f-b191-c3c3d323c3c3.yml up -d
[2024-05-08T20:39:45.846Z] parsing /tmp/devcontainercli-root/docker-compose/docker-compose.devcontainer.containerFeatures-1715200785780-516d96c0-3c67-479f-b191-c3c3d323c3c3.yml: yaml: unmarshal errors:
line 28: mapping key "build-obj" already defined at line 26
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.