devcontainers / devcontainers/cli

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

Abierto
#824 1 comentario 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
TypeScript
Estrellas
3k
Forks
457
Merge medio
13 h 17 min
PR fusionados (30 d)
6

Descripción

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
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.