How to Make ‘docker-compose’ Short and Quick Using Aliases

How to Make ‘docker-compose’ Short and Quick Using Aliases

Have you at times need to type docker-compose repeatedly to bring containers up and down or to check processes while in development? Here is a neat trick to shorten docker-compose to just 2 letters dc. This is a one-time change to your user SSH environment so that you will never have to do it again for future SSH sessions.

vi ~/.bashrc
# Custom Aliases
alias dc="docker-compose"

Save the file. Type the following command to reload the new updates in your current session without the need to log out and in.

$ source ~/.bashrc

If you try to enter dc now but it did not work, then this is due to these few lines of codes on top of the .bashrc file that runs your session non-interactively. I am on Debian 10 (buster) and it did not work for me too until I re-log into a new SSH session.

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

Conclusion

In this short tutorial, you had learnt to shorten lengthy Linux command for your SSH session to minimize typing time.

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *