Merge pull request #27857 from vasil-yordanov/docker-service-hostname-2

Adding the hostname option to docker service command
This commit is contained in:
Vincent Demeester 2016-11-04 15:22:55 +01:00 committed by GitHub
commit 38a582f54c
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.VarP(&opts.labels, flagLabel, "l", "Service labels")
flags.Var(&opts.containerLabels, flagContainerLabel, "Container 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.VarP(&opts.env, flagEnv, "e", "Set environment variables")
flags.Var(&opts.envFile, flagEnvFile, "Read in a file of 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") flags.Var(&opts.mounts, flagMount, "Attach a filesystem mount to the service")

View File

@ -316,6 +316,7 @@ type serviceOptions struct {
containerLabels opts.ListOpts containerLabels opts.ListOpts
image string image string
args []string args []string
hostname string
env opts.ListOpts env opts.ListOpts
envFile opts.ListOpts envFile opts.ListOpts
workdir string workdir string
@ -387,6 +388,7 @@ func (opts *serviceOptions) ToService() (swarm.ServiceSpec, error) {
Image: opts.image, Image: opts.image,
Args: opts.args, Args: opts.args,
Env: currentEnv, Env: currentEnv,
Hostname: opts.hostname,
Labels: runconfigopts.ConvertKVStringsToMap(opts.containerLabels.GetAll()), Labels: runconfigopts.ConvertKVStringsToMap(opts.containerLabels.GetAll()),
Dir: opts.workdir, Dir: opts.workdir,
User: opts.user, User: opts.user,
@ -486,6 +488,7 @@ const (
flagContainerLabelRemove = "container-label-rm" flagContainerLabelRemove = "container-label-rm"
flagContainerLabelAdd = "container-label-add" flagContainerLabelAdd = "container-label-add"
flagEndpointMode = "endpoint-mode" flagEndpointMode = "endpoint-mode"
flagHostname = "hostname"
flagEnv = "env" flagEnv = "env"
flagEnvFile = "env-file" flagEnvFile = "env-file"
flagEnvRemove = "env-rm" flagEnvRemove = "env-rm"