Add log_tag option to container definition

This adds the --log-opt tag=<value> to the docker run command, which can
be quite useful depending on your logging needs.

In the TripleO case, we use journald as the default logging driver, and
this will get reflected in the logs by adding the tag to the
CONTAINER_TAG key in the log metadata.

bp logging-stdout-rsyslog

Change-Id: I3bfb1a5ce2d6a6f95519f5272348eae18d649712
This commit is contained in:
Juan Antonio Osorio Robles 2017-10-05 09:55:54 +03:00
parent d11e04548e
commit e379a5b79e
4 changed files with 12 additions and 1 deletions

View File

@ -287,3 +287,6 @@ volumes:
volumes_from:
List of strings. Mount volumes from the specified container(s).
log_tag:
String. Set the log tag for the specified container.

View File

@ -173,6 +173,8 @@ class ComposeV1Builder(object):
for v in cconfig.get('volumes_from', []):
if v:
cmd.append('--volumes-from=%s' % v)
if 'log_tag' in cconfig:
cmd.append('--log-opt=tag=%s' % cconfig['log_tag'])
cmd.append(cconfig.get('image', ''))
cmd.extend(self.command_argument(cconfig.get('command')))

View File

@ -324,6 +324,7 @@ three-12345678 three''', '', 0),
'retries': 3
},
'env_file': '/tmp/foo.env',
'log_tag': '{{.ImageName}}/{{.Name}}/{{.ID}}'
}
}
builder = compose1.ComposeV1Builder('foo', config, None)
@ -337,7 +338,7 @@ three-12345678 three''', '', 0),
'--health-cmd=/bin/true', '--health-interval=30s',
'--health-timeout=10s', '--health-retries=3',
'--privileged=true', '--restart=always', '--user=bar',
'centos:7'],
'--log-opt=tag={{.ImageName}}/{{.Name}}/{{.ID}}', 'centos:7'],
cmd
)

View File

@ -0,0 +1,5 @@
---
features:
- |
the log_tag option was added to the container definition. This will make
paunch add the --log-opt tag=<value> option to the run command.