From 5b8c8718420671f7af2b0189299a55e43c252d5b Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 18 Nov 2015 10:47:25 -0700 Subject: [PATCH] If container name is already unique, don't append "-0" When using `--ensure-unique-name`, don't needlessly append `"-0"` if the container name is already unique. This is especially helpful with NixOps since when it deploys to a container it uses `--ensure-unique-name`. This means that the container name will never match the deployment host due to the `"-0"`. Having the container name and the host name match isn't exactly a requirement, but it's nice to have and a small change. --- nixos/modules/virtualisation/nixos-container.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 nixos/modules/virtualisation/nixos-container.pl diff --git a/nixos/modules/virtualisation/nixos-container.pl b/nixos/modules/virtualisation/nixos-container.pl old mode 100644 new mode 100755 index 004385f728c..eda57a9751e --- a/nixos/modules/virtualisation/nixos-container.pl +++ b/nixos/modules/virtualisation/nixos-container.pl @@ -97,10 +97,10 @@ if ($action eq "create") { if ($ensureUniqueName) { my $base = $containerName; for (my $nr = 0; ; $nr++) { - $containerName = "$base-$nr"; $confFile = "/etc/containers/$containerName.conf"; $root = "/var/lib/containers/$containerName"; last unless -e $confFile || -e $root; + $containerName = "$base-$nr"; } }