Commandes Linux : docker service update

DOCKER SERVICE UPDATE

Commande : docker service update
Usage:	docker service update [OPTIONS] SERVICE

Update a service

Options:
      --args command                       Service command args
      --config-add config                  Add or update a config file on a service
      --config-rm list                     Remove a configuration file
      --constraint-add list                Add or update a placement constraint
      --constraint-rm list                 Remove a constraint
      --container-label-add list           Add or update a container label
      --container-label-rm list            Remove a container label by its key
      --credential-spec credential-spec    Credential spec for managed service account (Windows only)
  -d, --detach                             Exit immediately instead of waiting for the service to converge
      --dns-add list                       Add or update a custom DNS server
      --dns-option-add list                Add or update a DNS option
      --dns-option-rm list                 Remove a DNS option
      --dns-rm list                        Remove a custom DNS server
      --dns-search-add list                Add or update a custom DNS search domain
      --dns-search-rm list                 Remove a DNS search domain
      --endpoint-mode string               Endpoint mode (vip or dnsrr)
      --entrypoint command                 Overwrite the default ENTRYPOINT of the image
      --env-add list                       Add or update an environment variable
      --env-rm list                        Remove an environment variable
      --force                              Force update even if no changes require it
      --generic-resource-add list          Add a Generic resource
      --generic-resource-rm list           Remove a Generic resource
      --group-add list                     Add an additional supplementary user group to the container
      --group-rm list                      Remove a previously added supplementary user group from the container
      --health-cmd string                  Command to run to check health
      --health-interval duration           Time between running the check (ms|s|m|h)
      --health-retries int                 Consecutive failures needed to report unhealthy
      --health-start-period duration       Start period for the container to initialize before counting retries towards unstable (ms|s|m|h)
      --health-timeout duration            Maximum time to allow one check to run (ms|s|m|h)
      --host-add list                      Add a custom host-to-IP mapping (host:ip)
      --host-rm list                       Remove a custom host-to-IP mapping (host:ip)
      --hostname string                    Container hostname
      --image string                       Service image tag
      --init                               Use an init inside each service container to forward signals and reap processes
      --isolation string                   Service container isolation mode
      --label-add list                     Add or update a service label
      --label-rm list                      Remove a label by its key
      --limit-cpu decimal                  Limit CPUs
      --limit-memory bytes                 Limit Memory
      --log-driver string                  Logging driver for service
      --log-opt list                       Logging driver options
      --mount-add mount                    Add or update a mount on a service
      --mount-rm list                      Remove a mount by its target path
      --network-add network                Add a network
      --network-rm list                    Remove a network
      --no-healthcheck                     Disable any container-specified HEALTHCHECK
      --no-resolve-image                   Do not query the registry to resolve image digest and supported platforms
      --placement-pref-add pref            Add a placement preference
      --placement-pref-rm pref             Remove a placement preference
      --publish-add port                   Add or update a published port
      --publish-rm port                    Remove a published port by its target port
  -q, --quiet                              Suppress progress output
      --read-only                          Mount the container's root filesystem as read only
      --replicas uint                      Number of tasks
      --reserve-cpu decimal                Reserve CPUs
      --reserve-memory bytes               Reserve Memory
      --restart-condition string           Restart when condition is met ("none"|"on-failure"|"any")
      --restart-delay duration             Delay between restart attempts (ns|us|ms|s|m|h)
      --restart-max-attempts uint          Maximum number of restarts before giving up
      --restart-window duration            Window used to evaluate the restart policy (ns|us|ms|s|m|h)
      --rollback                           Rollback to previous specification
      --rollback-delay duration            Delay between task rollbacks (ns|us|ms|s|m|h)
      --rollback-failure-action string     Action on rollback failure ("pause"|"continue")
      --rollback-max-failure-ratio float   Failure rate to tolerate during a rollback
      --rollback-monitor duration          Duration after each task rollback to monitor for failure (ns|us|ms|s|m|h)
      --rollback-order string              Rollback order ("start-first"|"stop-first")
      --rollback-parallelism uint          Maximum number of tasks rolled back simultaneously (0 to roll back all at once)
      --secret-add secret                  Add or update a secret on a service
      --secret-rm list                     Remove a secret
      --stop-grace-period duration         Time to wait before force killing a container (ns|us|ms|s|m|h)
      --stop-signal string                 Signal to stop the container
  -t, --tty                                Allocate a pseudo-TTY
      --update-delay duration              Delay between updates (ns|us|ms|s|m|h)
      --update-failure-action string       Action on update failure ("pause"|"continue"|"rollback")
      --update-max-failure-ratio float     Failure rate to tolerate during an update
      --update-monitor duration            Duration after each task update to monitor for failure (ns|us|ms|s|m|h)
      --update-order string                Update order ("start-first"|"stop-first")
      --update-parallelism uint            Maximum number of tasks updated simultaneously (0 to update all at once)
  -u, --user string                        Username or UID (format: [:])
      --with-registry-auth                 Send registry authentication details to swarm agents
  -w, --workdir string                     Working directory inside the container

 

Paramétrer le délai de mise à jour d’un service sur les nodes

$ docker service update [OPTIONS] --update-parallelism N --update-delay T service

On définit un rolling upgrade qui mettra les tâches à jour N par N toutes les T secondes.

  • --update-parallelism uint : Maximum number of tasks updated simultaneously (0 to update all at once)
  • --update-delay duration : Delay between updates (ns|us|ms|s|m|h)

ex :

$ docker service update --update-parallelism 2 --update-delay 15s vote
vote
overall progress: 6 out of 6 tasks
1/6: running   [==================================================>]
2/6: running   [==================================================>]
3/6: running   [==================================================>]
4/6: running   [==================================================>]
5/6: running   [==================================================>]
6/6: running   [==================================================>]
verify: Service converged

 

Mettre à jour l’image d’un service sur les nodes

$ docker service update [OPTIONS] --image image[:tag] service

ex :

$ docker service update --image instavote/vote:indent vote
vote
overall progress: 6 out of 6 tasks
1/6: running   [==================================================>]
2/6: running   [==================================================>]
3/6: running   [==================================================>]
4/6: running   [==================================================>]
5/6: running   [==================================================>]
6/6: running   [==================================================>]
verify: Service converged

 

Forcer la redistribution des tâches d’un service sur les nodes

$ docker service update --force service

ex :

$ docker service update --force vote_vote
vote_vote
overall progress: 2 out of 2 tasks
1/2: running   [==================================================>]
2/2: running   [==================================================>]
verify: Service converged

 

Scaler un service répliqué

$ docker service update --replicas N service

Equivaut à :
docker service scale service=N
ex :

$ docker service update --replicas 3 vote
vote
overall progress: 3 out of 3 tasks
1/3: running   [==================================================>]
2/3: running   [==================================================>]
3/3: running   [==================================================>]
verify: Service converged

 

Ajouter un secret à un service existant

$ docker service update --secret-add secret_name service

ex :

$ docker service update --secret-add dbuser mydb
mydb
overall progress: 1 out of 1 tasks
1/1: running   [==================================================>]
verify: Service converged

 

Supprimer un secret à un service existant

$ docker service update --secret-rm secret_name service

ex :

$ docker service update --secret-rm dbuser mydb
mydb
overall progress: 1 out of 1 tasks
1/1: running   [==================================================>]
verify: Service converged

 

Ajouter une config à un service existant

$ docker service update --config-add config_name service

ex :

$ docker service update --config-add my-config redis
redis
overall progress: 1 out of 1 tasks
1/1: running   [==================================================>]
verify: Service converged

 

Supprimer une config à un service existant

$ docker service update --config-rm config_name service

ex :

$ docker service update --config-rm my-config redis
redis
overall progress: 1 out of 1 tasks
1/1: running   [==================================================>]
verify: Service converged

 

Modifier le port publié pour un service

$ docker service update --publish-rm old-host-port --publish-add new-host-port:exposed-port service

Le port précédemment publié doit être supprimé en même temps que le nouveau est ajouté.
ex :

$ docker service update --publish-rm 8088 --publish-add 9090:80 mystack_drupal
mystack_drupal
overall progress: 1 out of 1 tasks 
1/1: running   [==================================================>] 
verify: Service converged

 

Fermer le menu
%d blogueurs aiment cette page :