diff --git a/README.md b/README.md index 5217233..849a635 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ To remove the service after it completes, run with the `--remove` or `-r` flag: ``` # jaas run --image alexellis2/href-counter:latest --env url=http://blog.alexellis.io/ -Service created: peaceful_shirley (uva6bcqyubm1b4c80dghjhb44) +Service created: jaas_peaceful_shirley (uva6bcqyubm1b4c80dghjhb44) ID: uva6bcqyubm1b4c80dghjhb44 Update at: 2017-03-14 22:19:54.381973142 +0000 UTC ... @@ -86,6 +86,8 @@ Printing service logs Removing service... ``` +To help you identify services created with jaas, the service name will be prefixed with jaas. + * Docker authentication for registries You can use `jaas` with Docker images in private registries or registries which require authentication. diff --git a/cmd/run.go b/cmd/run.go index f80cf4c..5b947a5 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -16,6 +16,7 @@ import ( "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" + "github.com/docker/docker/pkg/namesgenerator" "github.com/spf13/cobra" ) @@ -127,7 +128,11 @@ func runTask(taskRequest TaskRequest) error { spec.TaskTemplate.Placement = placement } - createResponse, _ := c.ServiceCreate(context.Background(), spec, createOptions) + createResponse, err := c.ServiceCreate(context.Background(), spec, createOptions) + if err != nil { + fmt.Println(err) + os.Exit(1) + } opts := types.ServiceInspectOptions{InsertDefaults: true} service, _, _ := c.ServiceInspectWithRaw(context.Background(), createResponse.ID, opts) @@ -153,6 +158,7 @@ func makeSpec(image string, envVars []string) swarm.ServiceSpec { }, }, } + spec.Name = "jaas_" + namesgenerator.GetRandomName(0) return spec }