MCPcopy
hub / github.com/docker/compose / getCanonicalContainerName

Function getCanonicalContainerName

pkg/compose/compose.go:332–345  ·  view source on GitHub ↗
(c container.Summary)

Source from the content-addressed store, hash-verified

330}
331
332func getCanonicalContainerName(c container.Summary) string {
333 if len(c.Names) == 0 {
334 // corner case, sometime happens on removal. return short ID as a safeguard value
335 return c.ID[:12]
336 }
337 // Names return container canonical name /foo + link aliases /linked_by/foo
338 for _, name := range c.Names {
339 if strings.LastIndex(name, "/") == 0 {
340 return name[1:]
341 }
342 }
343
344 return strings.TrimPrefix(c.Names[0], "/")
345}
346
347func getContainerNameWithoutProject(c container.Summary) string {
348 project := c.Labels[api.ProjectLabel]

Callers 15

LogsMethod · 0.85
copyMethod · 0.85
exportMethod · 0.85
TopMethod · 0.85
RemoveMethod · 0.85
projectFromNameMethod · 0.85
getContainerProgressNameFunction · 0.85
getLinksMethod · 0.85
PsMethod · 0.85
sortedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected