microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.67k stars 290 forks source link

Dev Containers: YAMLException for !reset [] tag #8734

Open seantfish opened 1 year ago

seantfish commented 1 year ago
[2023-07-20T21:44:03.339Z] Start: Updating configuration state
[2023-07-20T21:44:03.350Z] YAMLException: unknown tag !<!reset> (15:21)

 12 |   # Sonar node
 13 |   sonar_process:
 14 |     # exposing ports to Docker container for udp to ...
 15 |     ports: !reset []
--------------------------^
 16 |     # launches multiple ROS2 nodes, see sonar_proce ...
 17 |     command: sleep infinity
    at T6 (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:236:947)
    at ve (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:236:982)
    at xm (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:5823)
    at fEe (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:2158)
    at xm (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:4897)
    at fEe (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:2158)
    at xm (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:4897)
    at fEe (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:2158)
    at xm (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:4897)
    at vEe (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:7289)
    at I6 (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:244:260)
    at xEe (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:244:474)
    at SO (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:264:2634)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async X6 (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:264:1921)
    at async LC (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:264:1858)
    at async hbe (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:265:6019)
    at async jO (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:268:5194)

Steps to Reproduce:

  1. Create a devcontainer.json referencing two Docker Compose files ("dockerComposeFile") with one extending the other, with the first file setting up a service with a port defined under field ports and the extending file overriding that field with ports: !reset []
  2. Build and open container

Does this issue occur when you try this locally?: Yes Does this issue occur when you try this locally and all extensions are disabled?: No other extensions installed

!reset is a recent addition in the compose specification, but Docker is updated and able to parse the !reset tag and start the container. The issue appears to occur when the extension tries to read the file.

elgarfo commented 1 year ago

i'd like to add to that: the use of !reset null is met with the same error too.

[2023-08-16T11:43:41.501Z] YAMLException: unknown tag !<!reset> (3:23)

 1 | services:
 2 |   backend:
 3 |     build: !reset null
---------------------------^
 4 |     image: mcr.microsoft.com/devcontainers/python:1-3. ...
 5 |     command: sleep infinity
    at N6 (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:243:947)
    at ve (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:243:982)
    at Em (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:5823)
    at TEe (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:2158)
    at Em (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:4897)
    at TEe (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:2158)
    at Em (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:4897)
    at TEe (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:2158)
    at Em (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:4897)
    at AEe (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:7289)
    at L6 (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:251:260)
    at kEe (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:251:474)
    at kO (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:271:2634)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async iK (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:271:1921)
    at async qC (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:271:1858)
    at async Pbe (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:272:6047)
    at async zO (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:275:5396)

official compose documentation can be found here: https://docs.docker.com/compose/compose-file/13-merge/

elgarfo commented 1 year ago

at least i found a workaround. although this requires docker compose on the host:

the idea is to use docker compose -f docker-compose.yml -f docker-compose.devcontainer.yml config to get the rendered compose config. then store that and configure devcontainer.json to use that rendered file.

i've modified my devcontainer.json to this:

{
  "name": "dc/py3",
  "initializeCommand": "docker compose -f ./docker-compose.yml -f .devcontainer/docker-compose.devcontainer.yml config > .docker-compose.rendered.yml",
  // "dockerComposeFile": [ "../docker-compose.yml", "./docker-compose.devcontainer.yml" ],
  "dockerComposeFile": "../.docker-compose.rendered.yml",
  "service": "backend",
  "workspaceFolder": "/workspace",
  "shutdownAction": "stopCompose",
  "runServices": [ "rabbitmq" ]
}

⚠️ the "initializeCommand" is executed inside the projects root. NOT inside of .devcontainer/

i've tested this on windows 11 with docker (and docker compose) installed inside a debian 11 WSL2.

the lifecycle hook "initializeCommand" is documented here: https://containers.dev/implementors/json_reference/#lifecycle-scripts

chrmarti commented 1 year ago

There appears to be a way to add custom tags to the js-yaml module we are using for parsing: https://github.com/nodeca/js-yaml/blob/master/examples/handle_unknown_types.js

g-kartik commented 7 months ago

I am facing the same issue. @chrmarti can we please solve this issue?

g-kartik commented 7 months ago

Same goes for override tag too. It is also not recognized.