You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Adding labels to containers build by devcontainer cli #837
I have a case where I need to add some specific metadata to a dev-container image build by the dev-container cli.
would it make sense to add a parameter for this to the devcontainer build command?
My use case is that I want to use dev-container build to build images in the CI for reusability and would need some kind of metadata to identify the content of a built image.
Currently, you can achieve this by adding a LABEL in your Dockerfile or pass it as build.options in .devcontainer.json (see eg)
However, I think it would make sense to add a parameter for this to the devcontainer build command. Metadata can be very useful for tracking and managing images, especially in a CI/CD environment.
We can add a --label parameter to the devcontainer build command that allows users to specify key-value pairs. These pairs could then be added to the image as labels during the build process. In the implementation of the devcontainer build command, we would need to parse these labels and pass them to the Docker build command using the -l or --label option.
Yes, this would be exactly what I need.
Currently, I build a temporary Dockerfile which contains the image-tag where I need to add the label and then use docker build with that Dockerfile and just add the label as command line parameter and tag the image with the same tag. Works but just having the --label on the devcontainer cli would be much easier.
In bash this would look like: echo "FROM <myImage>" | docker build --label myNewLabel="myLabelValue" -t "<myImage>" -
Activity
samruddhikhandale commentedon Jun 5, 2024
Hi 👋
Currently, you can achieve this by adding a LABEL in your Dockerfile or pass it as
build.optionsin.devcontainer.json(see eg)However, I think it would make sense to add a parameter for this to the
devcontainer buildcommand. Metadata can be very useful for tracking and managing images, especially in a CI/CD environment.We can add a
--labelparameter to thedevcontainer buildcommand that allows users to specify key-value pairs. These pairs could then be added to the image as labels during the build process. In the implementation of thedevcontainer buildcommand, we would need to parse these labels and pass them to the Docker build command using the-lor--labeloption.Roemer commentedon Jun 6, 2024
Yes, this would be exactly what I need.
Currently, I build a temporary
Dockerfilewhich contains the image-tag where I need to add the label and then usedocker buildwith thatDockerfileand just add the label as command line parameter and tag the image with the same tag. Works but just having the--labelon the devcontainer cli would be much easier.In bash this would look like:
echo "FROM <myImage>" | docker build --label myNewLabel="myLabelValue" -t "<myImage>" -samruddhikhandale commentedon Jun 6, 2024
Christof Marti (@chrmarti) Any concerns with supporting a new
--labelproperty for thedevcontainer buildcommands?chrmarti commentedon Jun 7, 2024
Makes sense 👍
prathameshzarkar9 commentedon Jun 14, 2024
Hi Samruddhi Khandale (@samruddhikhandale) ,
feature added to pass the --label to devcontainer cli. Created PR #846
Kindly review and approve the same. Thank you
Merge pull request #846 from prathameshzarkar9/devcontainer-cli-add-l…