daemon: Fix mounting same image multiple times with different destinations#50268
daemon: Fix mounting same image multiple times with different destinations#50268vvoland merged 1 commit intomoby:masterfrom
Conversation
daemon/volumes.go
Outdated
| // This makes sure that the same image can be mounted multiple times with different destinations. | ||
| // Hash the destination to create a safe, unique identifier | ||
| destHash := sha256.Sum256([]byte(container.ID + "src=" + mp.Source + "dst=" + mp.Destination)) | ||
| layerName := hex.EncodeToString(destHash[:]) |
There was a problem hiding this comment.
Would we need to correlate the ID with these anywhere? Considering if (e.g.) base64 encoding or something like that would work instead of a cryptographic hash.
What are the constraints on these names? (is this path on disk, or otherwise?)
There was a problem hiding this comment.
We don't really need to correlate these, we just need "a" name for the snapshot. I think it could only be problematic when trying to match the name when filtering snapshots?
Also not sure if there's a length limit on snapshot ids.
There was a problem hiding this comment.
Changed to hex-encoding, so it's reversible in case it's needed.
5ffc521 to
07885d8
Compare
…tions The previous implementation generated layer names based on container ID and source image, which would cause conflicts when mounting the same image to multiple destinations within a container. This fixes the issue by changing the layer naming strategy to include the destination path in the layer name, making it unique for each mount point. To avoid filesystem paths producing unexpected names, the combined string is hex-encoded and used as a layer name. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
07885d8 to
14d9be4
Compare
|
This fix seems to break image mounts completely depending on the filesystem (?) #51687 |
|
You're absolutely right! /s I restored hashing the mount paths to avoid that and opened a PR: #51827 Thanks for a ping! |
The previous implementation generated layer names based on container ID and source image, which would cause conflicts when mounting the same image to multiple destinations within a container.
This fixes the issue by changing the layer naming strategy to include the destination path in the layer name, making it unique for each mount point.
To avoid filesystem paths producing unexpected names, the combined string is hex-encoded and used as a layer name.
- How to verify it
TestRunMountImageMultipleTimes
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)