32

Useful docker aliases

alias dstart='docker start "$@"'
alias dstop='docker stop "$@"'
alias drm='docker rm "$@"'
alias dip='docker inspect --format "{{ .NetworkSettings.IPAddress }}" "$@"'
alias dls="docker ps"
alias dlsa="docker ps -a"
alias dps="docker ps"
alias dimg='docker images "$@"'
alias drestart='docker restart "$@"'
alias dcommit='docker commit "$@"'
alias dinspect='docker inspect "$@"'
alias dlogs='docker logs "$@"'
alias dcp='docker cp "$@"'
alias dinfo='docker info'
alias dcompose='docker-compose "$@"'
alias dlogs='docker logs "$@"'
alias drshell='docker exec -it -u 0 "$@"'

Comments
  • 2
    Thank you for the idea, and welcome!
  • 3
    @Jilano Thanks Dude
  • 2
  • 1
    Nice. Could you elaborate what `$@` does? I'm guessing just pass all arguments to it, but then why would you need it at all?
  • 1
    Don't forget 'docker ps -aq | xargs docker rm -f' to remove all containers
  • 1
  • 2
    @Wack Yes, you are right. '$@' pass all arguments to it as bash alias does not support position based parameter passing (indirectly it is possible). The main idea of this alias is to have a shortcut to the docker commands instead of typing the complete one. Hope it clarifies.
  • 3
    @Override Typically we need to remove containers which are intermediate ones (creating while doing docker build) and one by referring its id/name but this shortcut is useful when you want to remove all the containers.
  • 0
    Alias laradock="cd Docker/laradock"

    dc() {
    laradock;
    docker-compose "$@";
    cd -;
    }

    Useful when working with laradock, from your working project directory you can just write dc up -d nginx and enjoy :D
  • 3
    Thanks!
  • 0
    Alias dsrall=
  • 0
    alias d="docker"
    alias dc="docker-compose"

    And call it a day
Add Comment