Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing options to docker service update from yml file #41241

Open
vitalets opened this issue Jul 21, 2020 · 5 comments
Open

Allow passing options to docker service update from yml file #41241

vitalets opened this issue Jul 21, 2020 · 5 comments
Labels
area/swarm kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny version/19.03

Comments

@vitalets
Copy link

vitalets commented Jul 21, 2020

Description
I'm deploying several independent services to swarm cluster.
Currently docker service update command accepts spec change via xxx-add / xxx-rm cli flags (see #25303).
Frankly, it looks to me not very convenient. Instead of having declarative description of service state I need to provide imperative instructions leading to some state.

I've tried two workaround to define service in file:

  1. Describe each service in own docker-stack.yml file and deploy each service via docker stack deploy. Having deployment config in yml file is very convenient. But using docker stack has for me following disadvantages:

    • docker stack deploy still does not have --detach mode. It means I can't see deploy result and deploy logs - it's blocker for me. In contrast I really like the output of docker service update command and it supports --detach mode.
    • creating separate stack for every service looks like overhead. Stack assumes several bound services. Using stack just to be able to define config in file is not conceptually correct imho. Also it generates redundant service names $STACK_$SERVICE instead of just myservice.
  2. Describe service deployment in shell script with docker service update. E.g.

# deploy.sh
docker service update \
  --replicas 3 \
  --network-add traefik \
  --label-add traefik.enable=true \
  ...
  myservice

But it does not work, as for example if service already added to network traefik, the command fails.

Proposal
Add cli flag --compose-file to docker service update:

docker service update --compose-file docker-stack.yml myservice

With the following docker-stack.yml it should deploy only myservice:

version: "3.8"

services:
  myservice:
    image: $IMAGE
    deploy:
      replicas: 3
      labels:
        traefik.enable: "true"
      restart_policy:
        condition: on-failure
        delay: 5s
       ...

In related issues several people were interested in providing full spec of service instead of delta.

Another alternative is to introduce docker service deploy command that will deploy particularly one service from stack file. Anyway the purpose is to allow declaratively describe service and deploy it.

I've investigated the source code of docker-cli - it seems apiClient.ServiceUpdate already accepts full service spec. So I hope it is possible to implement with not much effort.

Output of docker version:

See below
Client: Docker Engine - Community
 Azure integration  0.1.7
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        48a66213fe
 Built:             Mon Jun 22 15:41:33 2020
 OS/Arch:           darwin/amd64
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          19.03.12
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       48a66213fe
  Built:            Mon Jun 22 15:49:27 2020
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
@thaJeztah
Copy link
Member

Thanks for posting; could you describe why you would require multiple docker-compose files to update a service? If changes were made to a single service in the stack, only that service would be updated (or at least, it should 😅), so wondering why.

@thaJeztah thaJeztah added area/swarm kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny version/19.03 labels Jul 21, 2020
@vitalets
Copy link
Author

vitalets commented Jul 21, 2020

could you describe why you would require multiple docker-compose files to update a service?

I don't require multiple docker-compose files for service. I need single compose file per service.

@iquito
Copy link

iquito commented Oct 11, 2020

Having docker stack deploy and docker service update be more similar and being able to use a --compose-file for docker service update would be a great improvement. Because both commands work so differently it is easy to make mistakes, and for zero downtime updates you need docker service update.

Another possibility would be to have an additional command specifically for this (something like docker stack update) which then figures out what to change about the services based on a compose file. That command would basically find the deltas between the previous configuration and the given compose file, including volumes, environment variables and the used image.

@thaJeztah
Copy link
Member

thaJeztah commented Oct 11, 2020 via email

@iquito
Copy link

iquito commented Oct 12, 2020

Thanks, I didn't realize docker stack deploy supports that. Not having --detach is a pity though, that would make it a lot more useful.

An overview in the documentation about how docker stack and docker service commands relate to each other would have helped me a lot when trying to figure out how to use docker swarm (and they would still help now, to understand it better). That is probably how I ended up using docker service update, because it is referenced a lot more when trying to figure out how to do updates with docker swarm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/swarm kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny version/19.03
Projects
None yet
Development

No branches or pull requests

3 participants