Vscode-remote-release: Allow us to customize the container name that is generated

Created on 21 Mar 2020  路  5Comments  路  Source: microsoft/vscode-remote-release

Container names seem to be generated using the format vsc-{folder_name}-{hash_value}. This was a bit surprising because I assumed it was vsc-{devcontainer.json_name}-{hash_value}.

This may not seem problematic until you start to get into some advanced development techniques. In my case, I was attempting to improve the disk performance as suggested in the Microsoft documentation: https://code.visualstudio.com/docs/remote/containers-advanced#_improving-container-disk-performance

I wanted to keep any volume mounts I created together so that if I ever needed to delete the container I could easily identify the volumes that I may want to delete as well, so I created volumes with with names using the format vsx-{devcontainer.json_name}-node-modules. This was great, because all of my volume mounts were nearby each other:

  • dev-tracker-frontend-ui-node-modules
  • dev-tracker-frontend-ui-vscode-server-extensions
  • dev-tracker-frontend-ui-etc...

But, when I cloned the repository to the folder C:/Repos/Tracker/Website, the container that was generated was vsc-website-somehashvalue, which is just too generic, and as I start to use more and more projects it's going to get messy associating containers and volumes, as well as just identifying containers themselves (what happens when I have other repos in folders named website).

I could alter the way I structure the source code on my local machine, but it would be nice if either we were given an option to customize the name of the container or to use the devcontainer.json name property.

Most helpful comment

@myermian Try adding this to your devcontainer.json. This worked for me.
"runArgs": ["--name", "app"]

All 5 comments

Similar problem here. Documentation claims there is the ability to name the container, yet after removing the container and image the "name" property is never used when creating the container. I wonder if it's a bug, or maybe I missed something.

@myermian Try adding this to your devcontainer.json. This worked for me.
"runArgs": ["--name", "app"]

@myermian Try adding this to your devcontainer.json. This worked for me.
"runArgs": ["--name", "app"]

Well, it's a start. This at least labels the container appropriately in the Remote Explorer window, which in my case is workspace (dev-tracker-frontend-ui). However, under my Docker Containers it is still marked as dev-website-somehashvalue.

@myermian Try adding this to your devcontainer.json. This worked for me.
"runArgs": ["--name", "app"]

Thanks @bDarbonne , that's exactly what I was looking for!

Closing this out as it is similar to #2485.

Was this page helpful?
0 / 5 - 0 ratings