summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-11-23 12:39:48 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-11-23 12:48:10 +0100
commitda3c15e3c21fe8912172568a85a79859bb5bd22e (patch)
treee49321cf72ea8ef9d5be7c12d6640ddda1b61321 /src
parentbadd1a6968367dfc60ee2d38ddf20b0b530be10d (diff)
Build unique container name from job metadata
With this patch, the name of the running container is generated from the job metadata with a "butido-" prefix, so that containers on nodes can be identified (the auto-generated names from docker are funny, but help nobody). Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src')
-rw-r--r--src/endpoint/configured.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs
index e82901e..9073dc3 100644
--- a/src/endpoint/configured.rs
+++ b/src/endpoint/configured.rs
@@ -522,6 +522,13 @@ impl<'a> PreparedContainer<'a> {
let builder_opts = {
let mut builder_opts = shiplift::ContainerOptions::builder(job.image().as_ref());
+ let container_name = format!("butido-{package}-{version}-{id}",
+ package = job.package().name().as_ref(),
+ version = job.package().version().as_ref(),
+ id = job.uuid()
+ );
+ trace!("container name = {}", container_name);
+ builder_opts.name(&container_name);
builder_opts.env(envs.iter().map(AsRef::as_ref).collect::<Vec<&str>>());
builder_opts.cmd(vec!["/bin/bash"]); // we start the container with /bin/bash, but exec() the script in it later
builder_opts.attach_stdin(true); // we have to attach, otherwise bash exits