From 19b7bc17395a954841532206708cf319b5f9fbc0 Mon Sep 17 00:00:00 2001 From: Nikolay Milovanov Date: Thu, 27 Oct 2016 12:44:19 +0100 Subject: [PATCH] Adding the hostname option to docker service command Signed-off-by: Nikolay Milovanov --- command/service/create.go | 1 + command/service/opts.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/command/service/create.go b/command/service/create.go index 28790ec8e6..430d448565 100644 --- a/command/service/create.go +++ b/command/service/create.go @@ -33,6 +33,7 @@ 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 mount to the service") diff --git a/command/service/opts.go b/command/service/opts.go index 43b7b671cb..a134327356 100644 --- a/command/service/opts.go +++ b/command/service/opts.go @@ -455,6 +455,7 @@ type serviceOptions struct { containerLabels opts.ListOpts image string args []string + hostname string env opts.ListOpts envFile opts.ListOpts workdir string @@ -526,6 +527,7 @@ func (opts *serviceOptions) ToService() (swarm.ServiceSpec, error) { Image: opts.image, Args: opts.args, Env: currentEnv, + Hostname: opts.hostname, Labels: runconfigopts.ConvertKVStringsToMap(opts.containerLabels.GetAll()), Dir: opts.workdir, User: opts.user, @@ -625,6 +627,7 @@ const ( flagContainerLabelRemove = "container-label-rm" flagContainerLabelAdd = "container-label-add" flagEndpointMode = "endpoint-mode" + flagHostname = "hostname" flagEnv = "env" flagEnvFile = "env-file" flagEnvRemove = "env-rm"