In my ~/.zshrc i set up an alias
alias dkill="docker kill $(docker ps -q)"
but it does not actually run like the command itself does.
For some reason it tries to execute container names as commands instead of passing them to the docker kill command.
Error response from daemon: Cannot kill container: 3f1xxxxx0c4: No such container: 3f1xxxxx0c4
zsh: command not found: 0aexxxxxx913
zsh: command not found: 46acxxxx75cd
zsh: command not found: 20f9xxxxx9c1
zsh: command not found: 63edxxxxc085
zsh: command not found: 6328xxxxfe4d
How should i redefine the alias to kill containers properly
As @triplee says, the command is evaluated as soon as you define the alias (when you open you zsh session, container might not exist).
In your .zshrc use a function instead:
function dkill { docker kill $(docker ps -q) }
Or use single quotes:
alias dkill='docker kill $(docker ps -q)'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With