# docker bash command with autocompletion
# standard docker completion provided by docker-ce-cli

# enable debugging with this variable:
#export BASH_COMP_DEBUG_FILE=/dev/stdout

source /usr/share/bash-completion/completions/docker
function dbash() {
    docker exec -it "$1" bash;
}
function dbashwww() {
    docker exec -it "$1" su -s/bin/bash  www-data;
}
function dtail() {
    docker logs -f "$@";
}
_dbash() {
    #__start_docker loads variables itself and can't be used
    local cur prev words cword split
    cur="$2"
    words=(docker stop "$2")
    cword=2

    local out directive
    __docker_get_completion_results
    __docker_process_completion_results
}
complete -F _dbash dbash
complete -F _dbash dbashwww
complete -F _dbash dtail
