Mind Dump, Tech And Life Blog
written by Ivan Alenko

Development Tools Random Notes

Git search string in file across history

git log -S'bar' -- foo.rb

Git sign previous commits

Don’t rebase already pushed/merged commits in shared branches, you have to force push.

git rebase --exec 'git commit --amend --no-edit -n -S' -i my_branch

SSH copy SSH key to host automatically

Sets authorized_keys automatically.

ssh-copy-id -i ~/.ssh/myrtana.pub -f sandokan@myrtana.sk

Docker see logs

sudo docker ps
sudo docker logs -f 1234567abcd

Docker Remove All

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

docker system prune -a
docker system prune -a --volumes

Docker See Mem/Cpu Statistics

docker stats $(docker ps | awk '{if(NR>1) print $NF}')
sudo docker stats $(sudo docker ps | awk '{if(NR>1) print $NF}')

Docker Allows Access To Containers By Default

By default Docker allows access to containers from the outside! If it has public IP and no authentication on Redis, Memcached or Postgres/MySQL, they will be attacked and maybe hacked.

Check with:

iptables -L
iptables -L -t nat
nmap -p 1-10000 YOUR_PUBLIC_IP

More: https://sites.google.com/site/amitsciscozone/home/docker/docker-networking-basics

Docker List Volumes

docker inspect --format="{{.Mounts}}" $containerID