-
-
Save vladkrasovsky/5444ba072fb65c8fcc6faca3b8527ccc to your computer and use it in GitHub Desktop.
Docker aliases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add to /etc/hosts | |
# 127.0.0.1 localhost docker.local db mail | |
alias docker-host="echo docker.local" | |
alias drun="docker run -it --rm" | |
# Docker Compose | |
alias dc="docker-compose" | |
alias dc-run="dc run --rm" | |
alias dc-down="dc down -v --rmi local --remove-orphans" | |
function dc-port { | |
echo `docker-compose port $1 $2 | cut -d: -f2` | |
} | |
function dc-open { | |
local _open=open | |
type xdg-open >/dev/null 2>&1 && _open=xdg-open | |
$_open http://${DC_HOST:-`docker-host`}:`dc-port ${1:-web} ${2:-80}`$3 | |
} | |
# Databases | |
alias dc-db="dc-run db mysql -uroot -proot -hdb" | |
alias dc-dump-db="dc-run db mysqldump --extended-insert=FALSE -uroot -proot -hdb" | |
function dc-import-pg { | |
pv ${2:-$1.backup} | dc-run db pg_restore -U postgres -w -h db -d $1 | |
} | |
function dc-import-sql { | |
dc-db -e "DROP DATABASE $1; CREATE DATABASE $1;" | |
pv ${2:-$1.sql} | dc-db $1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment