I use Docker Swarm to test services on AWS. I recently applied an update for a service as follows:
docker service update
The update worked as intended, and the service updated the task containers to version v2. However, a quick docker service ps TestService2 | grep "v1"
docker service ps TestService2 | grep "v1"
shows a lot of shutdown TestImage:v1
tasks.
a0w77kj0k6jfg4r9g4nz47zzg \_ TestService2.1 TestImage:v1 W1 Shutdown Shutdown 36 minutes ago 2of4mc63ekzbib01w3x7q6sdm \_ TestService2.2 TestImage:v1 W2 Shutdown Shutdown 37 minutes ago 495frrpza5pxt205o1594x54a \_ TestService2.3 TestImage:v1 W1 Shutdown Shutdown 36 minutes ago 57l0gsqd26u2e5gdj30w8mcn9 \_ TestService2.4 TestImage:v1 M1 Shutdown Shutdown 36 minutes ago baoe1i79fswb34ydwbpafg6tm \_ TestService2.5 TestImage:v1 M3 Shutdown Shutdown 35 minutes ago 3uxi7kwxb73z69km6s17son58 \_ TestService2.6 TestImage:v1 M2 Shutdown Shutdown 37 minutes ago 99cg4arnt1y52nd8d422bdu49 \_ TestService2.7 TestImage:v1 M3 Shutdown Shutdown 36 minutes ago cq5716jqp40h6jugo1j9ilzwp \_ TestService2.8 TestImage:v1 M1 Shutdown Shutdown 35 minutes ago awlz1kxbrjk51dey7frm14d8u \_ TestService2.9 TestImage:v1 W3 Shutdown Shutdown 35 minutes ago 4xdi9a1jweyehfqlt76uynf3i \_ TestService2.10 TestImage:v1 M2 Shutdown Shutdown 36 minutes ago eo4t6i0gaj5i294fcdnb3qncq \_ TestService2.11 TestImage:v1 W3 Shutdown Shutdown 35 minutes ago 3ydeuxdjquulv5xj94b9ovuwu \_ TestService2.12 TestImage:v1 W1 Shutdown Shutdown 36 minutes ago
How can I delete them without going to each node swarm and running docker rm
in outgoing containers? I don’t think there is a docker service
for this, I looked through the documents, but does anyone know of a hack or script that I can run in Swarm Manager to clean the nodes?
Thanks!
source share