Adding the hostname option to docker service command

Signed-off-by: Nikolay Milovanov <nmil@itransformers.net>
This commit is contained in:
Nikolay Milovanov 2016-10-27 12:44:19 +01:00
parent e279ecacc5
commit 19b7bc1739
2 changed files with 4 additions and 0 deletions

View File

@ -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")

View File

@ -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"