DEV Community

Cover image for Don't like long, verbose Docker-compose command?
Aleksandr Korolev
Aleksandr Korolev

Posted on


Don't like long, verbose Docker-compose command?

Nowadays many developers and companies use Docker and Docker-compose in everyday live. I don't want to repeat what Docker is and why you might want to use it. But what I don't like when I work with Docker (if be more precisely with Docker-compose) - verbosity of commands.

It is hard to argue that Docker-compose provide good alternative compare with pure Docker interface but commands are still long and verbose. "It is not a problem" - you could reply, - "just add appropriate alias for the command and save time and effort". Yes, right, it can help in terminal but you are as a developer probably use IDE or at least text editor and often you have mechanisms for interact with your application somehow: run test, initialise building process etc. And not all IDEs and text-editors know how work with Docker.

From my point of view, the ideal setup is when you don't need to think about if you use Docker or not. For example, I need to run my tests with rspec (I'm a Rails-developers and all examples below are from Rails world), it would be great not to think about what should I do in order to run them - my habit is rspec path/to/specs but when my app is in Docker I should do something like this:

docker-compose run -rm container-name command

And in this case this utility can safe us.
DIP has two possible modes:

  1. dip your_command - in this mode you just need to type dip before your command, something like this: dip rails c
  2. your_command - DIP can be injected into the current shell and it analyses current directory if there is an dip.yml file, if the file is exist it runs a command in docker if not in a shell. But before this sunny live you need to create dip.yml - a configuration file when you should make mapping specific commands to appropriate container.

Possible pitfalls:
I use vim for development and by default vim didn't use dip when I tried to run command from vim. The problem was in an approach which vim uses when run external command - it doesn't load your shell's profile by default. In order to force it I've added next to my .vimrc

set shell=bash\ -l

Top comments (0)