Use HostConfig.Mounts for anonymous volumes #2618
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Containerlab passes all strings from the node "binds" property to Docker via the HostConfig.Binds field. This API supports anonymous volumes and the container does correctly start up with an new anonymous volume attached. But the volume itself is missing the "Name" attribute for some reason (docker inspect). This makes it impossible to then access the volume from other containers, like with
docker run --volumes-from <existing-container> .... An anonymous volume created with the new Mounts spec is for all intents and purposes equivalent to one created with Binds, except it has the "Name" attribute set to its random ID.This has worked in the past, so maybe there is a regression in Docker? Anyway by fixing it here we can ensure it will work for all Docker versions while maintaining compatibility with existing containerlab topologies.
As a side note, while I was reviewing the Docker documentation, I noticed my change to add anonymous volume support to containerlab node
bindsin #1853 mixes up two distinct concepts: Bind mounts and Volumes. In hindsight this feels like a mistake and volumes would be better handled in a newvolumesnode field. This would also align the syntax with docker-compose. What is the design guideline here?