Update fzf location
[dotfiles] / .bash_docker
1 #!/bin/sh
2
3 # ------------------------------------
4 # Docker aliases
5 # ------------------------------------
6
7 # Get latest container ID
8 alias d.l="docker ps -l -q"
9
10 # Get process included stop container
11 alias d.ps="docker ps -a"
12
13 # Get images
14 alias d.i="docker images -a"
15
16 # Get container IP
17 alias d.ip="docker inspect --format '{{ .NetworkSettings.IPAddress }}'"
18
19 # Exec interactive container, e.g., $ d.x base /bin/bash
20 alias d.x="docker exec -i -t"
21
22 # Remove dangling images
23 alias d.rmdi="docker rmi $(docker images -f "dangling=true" -q)"
24
25
26 # ------------------------------------
27 # Docker function
28 # alias blah='function _blah(){ echo "First: $1"; echo "Second: $2"; };_blah'
29 # ------------------------------------
30
31 # Remove containers
32 #alias d.rmac='dkrmc() { for i in $(docker ps -a -a | awk "{print $1}"); do docker rm $i; done };dkrmc'
33 alias d.rmac='dkrmc() { for i in $(docker ps -a -q); do docker stop $i; docker rm $i; done };dkrmc'
34
35 # Dockerfile build, e.g., $dbu tcnksm/test
36 alias d.b='dkb() { docker build -t "$1" .; };dkb'
37
38 # launch a postgres db
39 alias d.db='ldb(){ docker run -d --name db -e POSTGRES_PASSWORD=xcgd -e POSTGRES_USER=xcgd -e POSTGRES_DB=xcgd-db postgres;};ldb'
40
41 # Bash into running container
42 # alias d.enter="dkbash() { docker exec -it $(docker ps -aqf "name=$1") bash; };dkbash"
43
44 # my_docker_enter_running_container(){
45 # local container=$1
46 # docker exec -it $container bash
47 # }
48
49 alias d.cntr='dkntr() { docker exec -it "$1" /bin/bash; }; dkntr'
50
51 # dbash is particularly useful when diagnosing a failed `docker build`.
52 # Just bashi the last generated image and re-run the failed command
53 # run bash for any image
54 alias d.intr='dkbashi() { docker run --rm -i -t -e TERM=xterm --entrypoint /bin/bash "$1"; };dkbashi'