diff --git a/cli/command/service/create.go b/cli/command/service/create.go index 96c9f36da1..ea078e43ad 100644 --- a/cli/command/service/create.go +++ b/cli/command/service/create.go @@ -33,7 +33,6 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command { flags.VarP(&opts.labels, flagLabel, "l", "Service labels") flags.Var(&opts.containerLabels, flagContainerLabel, "Container labels") - flags.StringVar(&opts.hostname, flagHostname, "", "Container hostname") flags.VarP(&opts.env, flagEnv, "e", "Set environment variables") flags.Var(&opts.envFile, flagEnvFile, "Read in a file of environment variables") flags.Var(&opts.mounts, flagMount, "Attach a filesystem mount to the service") diff --git a/cli/command/service/opts.go b/cli/command/service/opts.go index 90d0f99249..7e631743a9 100644 --- a/cli/command/service/opts.go +++ b/cli/command/service/opts.go @@ -570,6 +570,7 @@ func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) { flags.StringVarP(&opts.workdir, flagWorkdir, "w", "", "Working directory inside the container") flags.StringVarP(&opts.user, flagUser, "u", "", "Username or UID (format: [:])") + flags.StringVar(&opts.hostname, flagHostname, "", "Container hostname") flags.Var(&opts.resources.limitCPU, flagLimitCPU, "Limit CPUs") flags.Var(&opts.resources.limitMemBytes, flagLimitMemory, "Limit Memory") diff --git a/cli/command/service/update.go b/cli/command/service/update.go index 20a4fc5708..92329d1439 100644 --- a/cli/command/service/update.go +++ b/cli/command/service/update.go @@ -208,6 +208,7 @@ func updateService(flags *pflag.FlagSet, spec *swarm.ServiceSpec) error { updateEnvironment(flags, &cspec.Env) updateString(flagWorkdir, &cspec.Dir) updateString(flagUser, &cspec.User) + updateString(flagHostname, &cspec.Hostname) if err := updateMounts(flags, &cspec.Mounts); err != nil { return err } diff --git a/docs/reference/commandline/service_update.md b/docs/reference/commandline/service_update.md index 21a727f719..d40443344d 100644 --- a/docs/reference/commandline/service_update.md +++ b/docs/reference/commandline/service_update.md @@ -45,6 +45,7 @@ Options: --help Print usage --host-add list Add or update a custom host-to-IP mapping (host:ip) (default []) --host-rm list Remove a custom host-to-IP mapping (host:ip) (default []) + --hostname string Container hostname --image string Service image tag --label-add list Add or update a service label (default []) --label-rm list Remove a label by its key (default [])