summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2017-11-29 16:58:55 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-11-30 02:03:23 +0000
commit1f9c8942f1c384db6cf4093eeccfdd80d5ef6c3f (patch)
tree27a67b82745172a59fd0e4c61f57967b0f1b496a /libpod
parent742475885eee9a21232f24aa7528eb5e0022a42f (diff)
downloadpodman-1f9c8942f1c384db6cf4093eeccfdd80d5ef6c3f.tar.gz
podman-1f9c8942f1c384db6cf4093eeccfdd80d5ef6c3f.tar.bz2
podman-1f9c8942f1c384db6cf4093eeccfdd80d5ef6c3f.zip
Add randomly generates container names
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #88 Approved by: baude
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container.go3
-rw-r--r--libpod/runtime_ctr.go2
2 files changed, 3 insertions, 2 deletions
diff --git a/libpod/container.go b/libpod/container.go
index aa80fb4a5..e69037353 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -12,6 +12,7 @@ import (
"github.com/containers/storage"
"github.com/containers/storage/pkg/archive"
+ "github.com/docker/docker/pkg/namesgenerator"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/pkg/term"
spec "github.com/opencontainers/runtime-spec/specs-go"
@@ -329,7 +330,7 @@ func newContainer(rspec *spec.Spec) (*Container, error) {
ctr.state = new(containerRuntimeInfo)
ctr.config.ID = stringid.GenerateNonCryptoID()
- ctr.config.Name = ctr.config.ID // TODO generate unique human-readable names
+ ctr.config.Name = namesgenerator.GetRandomName(0)
ctr.config.Spec = new(spec.Spec)
deepcopier.Copy(rspec).To(ctr.config.Spec)
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index 594e35dc5..58074cc43 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -69,7 +69,7 @@ func (r *Runtime) NewContainer(spec *spec.Spec, options ...CtrCreateOption) (c *
}()
if err := r.state.AddContainer(ctr); err != nil {
- // TODO: Might be worth making an effort to detect duplicate IDs
+ // TODO: Might be worth making an effort to detect duplicate IDs and names
// We can recover from that by generating a new ID for the
// container
return nil, errors.Wrapf(err, "error adding new container to state")