From 24328c4620aef777154ae6c5a4e510fd3035e9e7 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Wed, 25 Nov 2020 17:24:27 +0100 Subject: [PATCH] Add container labels to improve compatibility with docker-compose Signed-off-by: Guillaume Tardif --- local/compose.go | 5 +++++ local/labels.go | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/local/compose.go b/local/compose.go index 3a0cb9868..5b2595533 100644 --- a/local/compose.go +++ b/local/compose.go @@ -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), } diff --git a/local/labels.go b/local/labels.go index 24dee33f7..876482b90 100644 --- a/local/labels.go +++ b/local/labels.go @@ -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 {