69 lines
1.4 KiB
Bash
69 lines
1.4 KiB
Bash
# show container's volumes.
|
|
alias docker_volumes="docker inspect -f '{{ .Mounts }}'"
|
|
|
|
# check if container exited.
|
|
alias docker_health="docker ps -a | grep Exited"
|
|
|
|
# prune everything.
|
|
alias docker_prune="docker system prune --volumes --all"
|
|
|
|
# short aliases.
|
|
# usage: dc [SERVICE]
|
|
alias dc="docker compose"
|
|
alias dcu="docker compose up -d"
|
|
alias dcd="docker compose down"
|
|
alias dcp="docker compose pull"
|
|
alias dcl="docker compose logs -f"
|
|
alias dcr="docker compose restart"
|
|
alias dcs="docker compose stop"
|
|
|
|
# down & up specified services.
|
|
# usage: dcdu [SERVICES]
|
|
dcdu()
|
|
{
|
|
dcd "${@}"
|
|
dcu "${@}"
|
|
}
|
|
|
|
# pull & up specified services.
|
|
# usage: dcpu [SERVICES]
|
|
dcpu()
|
|
{
|
|
dcp "${@}"
|
|
dcu "${@}"
|
|
}
|
|
|
|
# up & attach to logs for specified services.
|
|
# usage: dcul [SERVICES]
|
|
dcul()
|
|
{
|
|
dcu "${@}" && dcl "${@}"
|
|
}
|
|
|
|
# find out container's IP address.
|
|
# usage: docker_up <CONTAINER NAME>
|
|
docker_ip()
|
|
{
|
|
docker inspect -f '\''{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'\' $1 | sed "s/^.//" | sed "s/.$//"
|
|
}
|
|
|
|
# update all docker images.
|
|
docker_update()
|
|
{
|
|
docker images --format "{{.Repository}}:{{.Tag}}" | xargs -L1 docker pull
|
|
}
|
|
|
|
# autocomplete.
|
|
_dc_services()
|
|
{
|
|
_autocomplete "$(docker compose config --services 2> /dev/null)"
|
|
}
|
|
|
|
_dc_containers()
|
|
{
|
|
_autocomplete "$(docker ps --format "\""{{.Names}}"\"")"
|
|
}
|
|
|
|
complete -F _dc_services dcu dcd dcp dcl dcul dcdu dcr dcs dcpu
|
|
complete -F _dc_containers docker_volumes docker_ip
|