Docker

List and Delete All Docker Containers

This will list all Docker containers, and delete each one regardless of whether it's running or not. Good if you use Docker for dev containers and need to reset your state.

docker ps -a --format '{{.ID}}' | xargs -I{} docker rm -v {}

Another way to do this (thanks to @sonicrocketman):

docker ps -aq | xargs -I{} docker rm -vf {}

Dealing With Large Pulls Over Slow Connections

If you've got a slow internet connection and are trying to pull a large collection of images, you may encounter retries causing the entire pull to fail, not to mention multiple concurrent downloads sucking up all your bandwidth.

I found that the following Docker daemon configuration changes helped:

  • Set max-concurrent-downloads to 1

  • Bump max-download-attempts to something relativey high, like 20.

The resulting JSON would look a little like this:

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,

  "max-concurrent-downloads": 1,
  "max-download-attempts": 20
}

It won't speed up your pulls, but at least you can let them run in the background without the retries failing on you.

Last updated