Docker tips
Use docker in docker to drive docker from a container Working under windows, sometimes docker slow down. Sometimes you need to access to the MobyVM. With this line:
docker run --rm -ti -v "/var/run/docker.sock:/var/run/docker.sock" -v /:/host docker sh
you run a container which will removed upon exit. This container can access to docker daemon (via the docker in docker image) and has also access to MobyVM under the /host mount point. Keep in mind this container has total access to your windows C: disk too, so be careful! Find the total memory % used by your containers:
docker stats --no-stream --format "table \{\{.MemPerc\}\}" | sed 's/[A-Za-z]*//g' | awk '{sum += $1} END {print sum "%"}'
Tested with 18.06.1-ce, take a look at https://docs.docker.com/engine/reference/commandline/stats/ for docker stats syntax
UPDATE Find out what you can format: try with the json output
docker images --format='\{\{json .\}\}' #Delete only some image groups, doing a match via docker image command, instead of ugly grep docker images --format '\{\{.ID\}\}' daitangio | xargs docker rmi # Get service ids for further analisis via docker inspect: docker service ls --format "\{\{json .ID\}\}"
UPDATE 2020 How to remove down node from a cluster (dirty fast):
docker node ls --format '\{\{.ID\}\}:\{\{.Status\}\}' | grep Down | cut -d : -f 1 | xargs docker node rm