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" \