Docker remove container before remove image (#928)

* add docker container removal

* remove container before deleting image

* update readme

* clean up and add assert not test

* test not docker command

* use shell.and_ correctly
This commit is contained in:
Connor Martin
2019-07-10 13:34:20 -05:00
committed by Vladimir Iakovlev
parent 4c3a559124
commit 01a5ba99d0
3 changed files with 48 additions and 0 deletions
@@ -0,0 +1,20 @@
from thefuck.utils import for_app
from thefuck.shells import shell
@for_app('docker')
def match(command):
'''
Matches a command's output with docker's output
warning you that you need to remove a container before removing an image.
'''
return 'image is being used by running container' in command.output
def get_new_command(command):
'''
Prepends docker container rm -f {container ID} to
the previous docker image rm {image ID} command
'''
container_id = command.output.strip().split(' ')
return shell.and_('docker container rm -f {}', '{}').format(container_id[-1], command.script)