Add container labels to improve compatibility with docker-compose

Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
Guillaume Tardif 2020-11-25 17:24:27 +01:00
parent 9e1de51f82
commit 24328c4620
2 changed files with 15 additions and 3 deletions

View File

@ -363,10 +363,15 @@ func getContainerCreateOptions(p *types.Project, s types.ServiceConfig, number i
if err != nil {
return nil, nil, nil, err
}
//TODO: change oneoffLabel value for containers started with `docker compose run`
labels := map[string]string{
projectLabel: p.Name,
serviceLabel: s.Name,
versionLabel: ComposeVersion,
oneoffLabel: "False",
configHashLabel: hash,
workingDirLabel: p.WorkingDir,
configFilesLabel: strings.Join(p.ConfigNames(), ","),
containerNumberLabel: strconv.Itoa(number),
}

View File

@ -25,10 +25,17 @@ import (
)
const (
projectLabel = "com.docker.compose.project"
serviceLabel = "com.docker.compose.service"
configHashLabel = "com.docker.compose.config-hash"
containerNumberLabel = "com.docker.compose.container-number"
oneoffLabel = "com.docker.compose.oneoff"
projectLabel = "com.docker.compose.project"
workingDirLabel = "com.docker.compose.project.working_dir"
configFilesLabel = "com.docker.compose.project.config_files"
serviceLabel = "com.docker.compose.service"
versionLabel = "com.docker.compose.version"
configHashLabel = "com.docker.compose.config-hash"
//ComposeVersion Compose version
ComposeVersion = "1.0-alpha"
)
func projectFilter(projectName string) filters.KeyValuePair {