Create and use `${packageName}:${packageVersion}` for Node.js image tag
This was reproduced on Windows 10 2004, WSL2 Docker Desktop 2.3.0.0, Docker extension version 1.2.0, VS Code version 1.45.1
Repro steps:
- Create a simple Node.js app
- Scaffold Docker files using VS Code Docker extension
- Ensure that package.json has both
nameandversionproperties set (e.g.guestbook-expressand1.0.0, respectively). - Run
docker-buildtask
Expected: the resulting image should be tagged as guestbook-express:1.0.0--at least that was the intent of the design https://code.visualstudio.com/docs/containers/reference#_nodejs-dockerbuild
Actual: the resulting image is tagged as guestbookexpress:latest (note wrong tag and removed hyphen in the name).
Further problem:
5. Open tasks.json and set dockerBuild.tag property to guestbook-express:1.0.0
6. Run docker-build task again
Expected: the resulting image should be tagged as the task parameters say it should
Actual: nope, it is still guestbookexpress:latest 😠
@karolz-ms For now at least it's intentional that we do not use package.json's version though that's a reasonable change we could make. The most appropriate way to do it would be variable substitution, e.g.
"dockerBuild": {
"tag": "${packageName}:${packageVersion}"
}
The design says it will reuse the package.json name (which it does, though it removes dashes [another reasonable change we could make]), but does not say it will reuse the version.
I propose we use this issue to make two changes:
- Allow dashes in the image name wherever they are appropriate (which is anywhere in the middle of the tag/image name, i.e. not the first or last character).
- Create the above variable substitution parameters, and use them as the default tag. Continue to use package.json name +
:latestif there is nothing specified, so that those with previously-scaffolded Node.jsdocker-buildtasks do not encounter issues from changed behavior.
I was not able to reproduce second issue:

The "further problem" (steps 5 and 6) are a dup of https://github.com/microsoft/vscode/issues/98617
@bwateratmsft your proposal sounds very good to me
@karolz-ms Ok, I'll change the title to reflect what this bug is now about. :smile: