Skip to content

Adding labels to containers build by devcontainer cli #837

Closed

Description

@Roemer

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.

Activity

  1. samruddhikhandale commented on Jun 5, 2024

    @samruddhikhandale
    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.

  2. Roemer commented on Jun 6, 2024

    @Roemer
    Author

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

  3. samruddhikhandale commented on Jun 6, 2024

    @samruddhikhandale
    Member

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

  4. chrmarti commented on Jun 7, 2024

    @chrmarti
    Contributor

    Makes sense 👍

  5. prathameshzarkar9 commented on Jun 14, 2024

    @prathameshzarkar9
    Contributor

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

  6. added a commit that references this issue on Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions