Why does Docker show previous task for each service? I want to see only current tasks with the desired state "Running". I want clean up older tasks that have moved to a desired state other than "Running". How can this be achieved?
rus@coder:~/Docker$ docker stack ps getstartedlab
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
gp07knn0g5hl getstartedlab_redis.1 redis:latest myvm1 Ready Assigned less than a second ago
m31cmdrsoxns \_ getstartedlab_redis.1 redis:latest myvm1 Shutdown Rejected less than a second ago "invalid mount config for type…"
zjxzlx4hd5um \_ getstartedlab_redis.1 redis:latest myvm1 Shutdown Rejected 39 seconds ago "invalid mount config for type…"
zpi3nlsc338g \_ getstartedlab_redis.1 redis:latest myvm1 Shutdown Rejected 2 minutes ago "invalid mount config for type…"
xqpdhsyw54uh getstartedlab_web.1 motionrus/get-started:part2 myvm1 Running Running 7 minutes ago
jruvttjnvwn6 getstartedlab_visualizer.1 dockersamples/visualizer:stable myvm1 Running Running 7 minutes ago
g0f28ldwvftr getstartedlab_web.1 motionrus/get-started:part2 myvm1 Shutdown Failed 8 minutes ago "No such container: getstarted…"
zwn1mr6dsafs getstartedlab_redis.1 redis:latest myvm1 Shutdown Rejected about an hour ago "invalid mount config for type…"
zoi4p8rt0lmg \_ getstartedlab_redis.1 redis:latest myvm1 Shutdown Rejected about an hour ago "invalid mount config for type…"
czsb4iu1vx7b getstartedlab_web.1 motionrus/get-started:part2 myvm2 Shutdown Shutdown 6 minutes ago
oavyu08f2zpy getstartedlab_visualizer.1 dockersamples/visualizer:stable myvm1 Shutdown Failed 8 minutes ago "No such container: getstarted…"
ihisx81pn0jm getstartedlab_web.2 motionrus/get-started:part2 myvm1 Running Running 7 minutes ago
8fvkdyyzga5u \_ getstartedlab_web.2 motionrus/get-started:part2 myvm1 Shutdown Failed 8 minutes ago "task: non-zero exit (255)"
usotwci097ll \_ getstartedlab_web.2 motionrus/get-started:part2 myvm2 Shutdown Shutdown 6 minutes ago
js15t9lz0fip getstartedlab_web.3 motionrus/get-started:part2 myvm1 Running Running 7 minutes ago
we3brrn188ex \_ getstartedlab_web.3 motionrus/get-started:part2 myvm1 Shutdown Failed 8 minutes ago "task: non-zero exit (255)"
ed94zf05jnqq getstartedlab_web.4 motionrus/get-started:part2 myvm1 Running Running 7 minutes ago
p9ntyj4fl0dw \_ getstartedlab_web.4 motionrus/get-started:part2 myvm1 Shutdown Failed 8 minutes ago "task: non-zero exit (255)"
ipqdt5h8yb7p \_ getstartedlab_web.4 motionrus/get-started:part2 myvm2 Shutdown Shutdown 6 minutes ago
s2vdxejisg0d getstartedlab_web.5 motionrus/get-started:part2 myvm1 Running Running 7 minutes ago
yj4l496k8dky \_ getstartedlab_web.5 motionrus/get-started:part2 myvm1 Shutdown Failed 8 minutes ago "task: non-zero exit (255)"
I know, i use grep command, but it isn't best solution
rus@coder:~/Docker$ docker stack ps getstartedlab | grep "Running"
xqpdhsyw54uh getstartedlab_web.1 motionrus/get-started:part2 myvm1 Running Running 21 minutes ago
jruvttjnvwn6 getstartedlab_visualizer.1 dockersamples/visualizer:stable myvm1 Running Running 21 minutes ago
ihisx81pn0jm getstartedlab_web.2 motionrus/get-started:part2 myvm1 Running Running 21 minutes ago
js15t9lz0fip getstartedlab_web.3 motionrus/get-started:part2 myvm1 Running Running 21 minutes ago
ed94zf05jnqq getstartedlab_web.4 motionrus/get-started:part2 myvm1 Running Running 21 minutes ago
s2vdxejisg0d getstartedlab_web.5 motionrus/get-started:part2 myvm1 Running Running 21 minutes ago
Docker lists every container/task associated with the stack. You can use filters to get only those that should be running. If you want to have more or less containers kept around, there's an option to adjust the task history for each service. That can be set during install or updated with:
docker swarm update --task-history-limit 3
To see only running tasks according to official documentation one need to use filter flag -f
. In your case it will be docker stack ps -f "desired-state=running" getstartedlab
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.