Browse code

Allow hostname to be updated on service.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
(cherry picked from commit 1c65cb6657f1288d6a7e93e0015bba68e6d374cd)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>

Daniel Nephin authored on 2016/11/24 04:42:56
Showing 4 changed files
... ...
@@ -33,7 +33,6 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
33 33
 
34 34
 	flags.VarP(&opts.labels, flagLabel, "l", "Service labels")
35 35
 	flags.Var(&opts.containerLabels, flagContainerLabel, "Container labels")
36
-	flags.StringVar(&opts.hostname, flagHostname, "", "Container hostname")
37 36
 	flags.VarP(&opts.env, flagEnv, "e", "Set environment variables")
38 37
 	flags.Var(&opts.envFile, flagEnvFile, "Read in a file of environment variables")
39 38
 	flags.Var(&opts.mounts, flagMount, "Attach a filesystem mount to the service")
... ...
@@ -570,6 +570,7 @@ func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
570 570
 
571 571
 	flags.StringVarP(&opts.workdir, flagWorkdir, "w", "", "Working directory inside the container")
572 572
 	flags.StringVarP(&opts.user, flagUser, "u", "", "Username or UID (format: <name|uid>[:<group|gid>])")
573
+	flags.StringVar(&opts.hostname, flagHostname, "", "Container hostname")
573 574
 
574 575
 	flags.Var(&opts.resources.limitCPU, flagLimitCPU, "Limit CPUs")
575 576
 	flags.Var(&opts.resources.limitMemBytes, flagLimitMemory, "Limit Memory")
... ...
@@ -208,6 +208,7 @@ func updateService(flags *pflag.FlagSet, spec *swarm.ServiceSpec) error {
208 208
 	updateEnvironment(flags, &cspec.Env)
209 209
 	updateString(flagWorkdir, &cspec.Dir)
210 210
 	updateString(flagUser, &cspec.User)
211
+	updateString(flagHostname, &cspec.Hostname)
211 212
 	if err := updateMounts(flags, &cspec.Mounts); err != nil {
212 213
 		return err
213 214
 	}
... ...
@@ -45,6 +45,7 @@ Options:
45 45
       --help                             Print usage
46 46
       --host-add list                    Add or update a custom host-to-IP mapping (host:ip) (default [])
47 47
       --host-rm list                     Remove a custom host-to-IP mapping (host:ip) (default [])
48
+      --hostname string                  Container hostname
48 49
       --image string                     Service image tag
49 50
       --label-add list                   Add or update a service label (default [])
50 51
       --label-rm list                    Remove a label by its key (default [])