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

Function getContainerNameWithoutProject

pkg/compose/compose.go:347–356  ·  pkg/compose/compose.go::getContainerNameWithoutProject
(c container.Summary)

Source from the content-addressed store, hash-verified

345}
346
347func getContainerNameWithoutProject(c container.Summary) string {
348 project := c.Labels[api.ProjectLabel]
349 defaultName := getDefaultContainerName(project, c.Labels[api.ServiceLabel], c.Labels[api.ContainerNumberLabel])
350 name := getCanonicalContainerName(c)
351 if name != defaultName {
352 // service declares a custom container_name
353 return name
354 }
355 return name[len(project)+1:]
356}
357
358// projectFromName builds a types.Project based on actual resources with compose labels set
359func (s *composeService) projectFromName(containers Containers, projectName string, services ...string) (*types.Project, error) {

Callers 4

logContainerMethod · 0.85
attachMethod · 0.85
attachContainerMethod · 0.85
runHookMethod · 0.85

Calls 2

getDefaultContainerNameFunction · 0.85

Tested by

no test coverage detected