Created
November 19, 2015 15:05
-
-
Save ioggstream/dc5716be7801894db335 to your computer and use it in GitHub Desktop.
Docker shell profile.
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
dip(){ | |
# Show docker ips | |
local arg=${1} | |
if [ -z "$arg" ]; then | |
arg=$(docker ps -q) | |
fi | |
/bin/docker inspect --format ' {{.Name}} {{.NetworkSettings.IPAddress}}' $arg | |
} | |
# | |
# Docker Exec alias with auto-complete | |
# | |
dshell(){ | |
local container="$1" | |
local command="${2:-/bin/bash}" | |
/bin/docker exec -ti "$container" "$command" | |
} | |
_dshell() | |
{ | |
local cur prev opts | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
opts="$(docker inspect -f '{{.Name}}' $(docker ps -q))" | |
opts=${opts//\/} | |
if [[ ${cur} =~ [a-z]+ ]]; then | |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | |
return 0 | |
fi | |
} | |
complete -F _dshell dshell | |
dhown(){ | |
# Set docker permissions and context to the current directory | |
sudo chgrp -R docker "$@" | |
sudo chcon -Rt svirt_sandbox_file_t "$@" | |
} | |
fig(){ | |
/bin/docker-compose "$@" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment