Clean Up

Remove Unused Images

docker system prune

This removes:

  • all stopped containers
  • all networks not used by at least one container
  • all dangling images
  • all dangling build cache

Remove All Images

docker image rm -f $(docker images -a -q)


docker system prune --all

Start docker with SSH

On linux it should be possible to actually use SSH agent forwarding. See:

However, this doesn't work on MacOS. See:

But, you can of course just share your .ssh folder and start ssh-agent in the container.

Run Docker with .ssh

This uses a bind mount, which shares the files. Should probably use a volume to copy the files.

docker run --rm -it \
       --name sshtest \
       --mount type=bind,source=/Users/chrisc/.ssh,target=/root/.ssh \
       $ImageName \

In container, start ssh-agent

eval $(ssh-agent -s)

Add your keys

ssh-add ~/.ssh/id_rsa

Run Simple Images

Images I sometimes run for debugging etc.


Run and mount current dir.

PROJECT_NAME=$(basename $(pwd))

docker run --rm \
       --name $PROJECT_NAME \
       --mount type=bind,source=$(pwd),target=/$PROJECT_NAME \
       python:3.6.5-slim-stretch /bin/bash


Run golang container for interactive use

docker run -it --rm golang:1.14

Rate Limiting

curl "" \
    | jq -r .token
curl --head \
     -H "Authorization: Bearer $TOKEN" \
HTTP/1.1 200 OK
Content-Length: 2782
Content-Type: application/vnd.docker.distribution.manifest.v1+prettyjws
Docker-Content-Digest: sha256:767a3815c34823b355bed31760d5fa3daca0aec2ce15b217c9cd83229e0e2020
Docker-Distribution-Api-Version: registry/2.0
Etag: "sha256:767a3815c34823b355bed31760d5fa3daca0aec2ce15b217c9cd83229e0e2020"
Date: Mon, 07 Dec 2020 21:19:08 GMT
Strict-Transport-Security: max-age=31536000
RateLimit-Limit: 100;w=21600
RateLimit-Remaining: 100;w=21600