devcontainers / cli

A reference implementation for the specification that can create and configure a dev container from a devcontainer.json.
https://containers.dev
MIT License
1.6k stars 222 forks source link

`devcontainer up` should allow container name customization #306

Open vHanda opened 1 year ago

vHanda commented 1 year ago

I often use devcontainer up to start the container, but then it's often difficult to know which of my many containers has been created for this devcontainer.

It would be awesome if we could have some `--name x' feature where I could customize the name.

chrisguest75 commented 1 year ago

You can add a label, but weirdly I'm finding this hangs the cli tool before running the postCreateCommand. Would be interested to see if others see this behaviour.

Update: This works if you use --id-label containername=${_CONTAINERNAME} instead of --id-label name=${_CONTAINERNAME}

So this would be a workaround. It doesn't negate request for supporting a container name parameter.

# add label
devcontainer up --id-label name=${_CONTAINERNAME} --remove-existing-container --config "./devcontainer.json"
# find container
docker ps -aqf label=name=${_CONTAINERNAME}