Skip to content

Fix scripts/rm: use xargs to properly handle the newline-separated output in variables

Fridtjof requested to merge fridtjof/fix-rm-script into master

Closes #959 (closed)

Previously, this would always error out due to the output from docker ps (or docker volume ls) being newline separated.

Passing that as a single argument to other docker commands (by quoting the variable) will ask them to remove a container called (for example):

"ad7f74dc8d3b
ef7f74ddf7f7
"

Docker will then say:

Error: No such container: 644d15c0dbcd
ef7f74ddf7f7

This looks like docker just didn't like the first container, but still removes all other containers. The script then aborts, because docker returns a non zero exit code. Any other cleanup steps coming afterwards are not executed, leading to a partially cleaned docker environment which can break (and has broken!) further attempts to recreate the environment.

Edited by Fridtjof

Merge request reports