Global variable that can be used for labels or consistent names/prefixes for docker resource
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6.1k
- Forks
- 2.2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 43
Description
Description
So I have an issue when I have a single host that is being used in CI that has multiple spawns of CI steps that can run in parallel.
The issue that this causes is that we would have to deal with parallel docker work on the same host and not collide with names or any docker resources as well as being able to determine a name in some way so we can clean up our hosts potentially before the CI runs and after. Ultimately cleaning the slate after the job runs and before it begins.
The way I'm currently doing this now is setting a label on all the resources and then using a post and pre command hook to use those labels to search for any containers/networks/volumes etc.... that match that label and delete them. Reason we want to do this is for things like exposed networks, colliding names, etc... we just want to ensure that there is a seamless and abstracted way for docker to run and not have any collisions.
I would love to not need to specify a label like this on each individual docker command and instead have some native docker way to achieve this goal... one way I thought of doing this was having an environment variable that can be exported like:
DOCKER_LABELS="key=value,other_key=value"
Or even better someway to determine or create a "namespace" for each docker spawn on the same host, it doesn't neccessarily have to be a label mechanism, even a prefix or something for names. I just need to be able to determine that X docker resources were created with Y spawn on the same host. So in my example I could have 4 spawns on a single host and want to clearly know which spawn created which resources and then I can run my cleanup of the docker resources cleanly.
After going through the documentation heavily I have seen that this can kind of be achieved with "contexts" but this would require me to run multiple docker daemons/sockets and configure it that way. That feels incredibly complicated for this kind of task and I would rather do it with something like above or a config file that gets loaded.
There might be a way for me to achieve this isolation/separation but I could not find anywhere in the documentation that explains this. Any help or at least direction if this exists in a way that can be done with what we have or whether or not this is a new feature that would need to be implemented.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Docker CLI documentation on labels and contexts, then compare those mechanisms with the reported pre- and post-command cleanup workflow. Clarify whether the goal is documented guidance for existing isolation or a new global-label or resource-namespace feature. Done means the supported approach and its scope are explicitly established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker
- Domain
- cli, devops
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100