Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding labels to containers build by devcontainer cli #837

Closed
Roemer opened this issue Jun 5, 2024 · 5 comments · Fixed by #846
Closed

Adding labels to containers build by devcontainer cli #837

Roemer opened this issue Jun 5, 2024 · 5 comments · Fixed by #846
Assignees
Labels
feature-request New feature or request

Comments

@Roemer
Copy link

Roemer commented Jun 5, 2024

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.

@samruddhikhandale
Copy link
Member

Hi 👋

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.

@samruddhikhandale samruddhikhandale added the feature-request New feature or request label Jun 5, 2024
@Roemer
Copy link
Author

Roemer commented Jun 6, 2024

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>" -

@samruddhikhandale
Copy link
Member

@chrmarti Any concerns with supporting a new --label property for the devcontainer build commands?

@chrmarti
Copy link
Contributor

chrmarti commented Jun 7, 2024

Makes sense 👍

@prathameshzarkar9
Copy link
Contributor

Hi @samruddhikhandale ,
feature added to pass the --label to devcontainer cli. Created PR #846
Kindly review and approve the same. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants