feat(api): add GetContainer endpoint and Docker host ID mapping

- Implemented GetContainer function to retrieve container details by ID.
- Introduced idDockerHostMap for mapping container IDs to Docker hosts.
- Updated Container struct to allow omitting the State field in JSON responses.
This commit is contained in:
yusing
2025-09-04 06:36:02 +08:00
parent 90738a6809
commit 20105534c7
3 changed files with 81 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
package docker
import (
"github.com/puzpuzpuz/xsync/v4"
)
var idDockerHostMap = xsync.NewMap[string, string]()
func GetDockerHostByContainerID(id string) (string, bool) {
return idDockerHostMap.Load(id)
}
func SetDockerHostByContainerID(id, host string) {
idDockerHostMap.Store(id, host)
}
func DeleteDockerHostByContainerID(id string) {
idDockerHostMap.Delete(id)
}