Repository: nvbn/thefuck (Python)

Issue:
Help with `docker image rm`
<!-- If you have any issue with The Fuck, sorry about that, but we will do what we
can to fix that. Actually, maybe we already have, so first thing to do is to
update The Fuck and see if the bug is still there. -->

<!-- If it is (sorry again), check if the problem has not already been reported and
if not, just open an issue on [GitHub](https://github.com/nvbn/thefuck) with
the following basic information: -->

The output of `thefuck --version` (something like `The Fuck 3.1 using Python
3.5.0 and Bash 4.4.12(1)-release`):

    The Fuck 3.29 using Python 3.7.3 and ZSH 5.7.1

### Your system (Debian 7, ArchLinux, Windows, etc.):

    macOS Mojave 10.14.5

How to reproduce the bug:

    Try to remove a docker image for which a container is still running.

```bash
$ docker image rm -f cd809b04b6ff
Error response from daemon: conflict: unable to delete cd809b04b6ff (cannot be forced) - image is being used by running container e5e2591040d1
$ fuck
docker image rm -f cd809b04b6ff [enter/↑/↓/ctrl+c]
```

The output of The Fuck with `THEFUCK_DEBUG=true` exported (typically execute `export THEFUCK_DEBUG=true` in your shell before The Fuck):

<details>
<summary>Click for output</summary>

```bash
DEBUG: Run with settings: {'alter_history': True,
 'debug': True,
 'env': {'GIT_TRACE': '1', 'LANG': 'C', 'LC_ALL': 'C'},
 'exclude_rules': [],
 'history_limit': None,
 'instant_mode': False,
 'no_colors': False,
 'num_close_matches': 3,
 'priority': {},
 'repeat': False,
 'require_confirmation': True,
 'rules': [<const: All rules enabled>],
 'slow_commands': ['lein', 'react-native', 'gradle', './gradlew', 'vagrant'],
 'user_dir': PosixPath('/Users/me/.config/thefuck'),
 'wait_command': 3,
 'wait_slow_command': 15}
DEBUG: Received output: Error response from daemon: conflict: unable to delete cd809b04b6ff (cannot be forced) - image is being used by running container e5e2591040d1

DEBUG: Call: docker image rm -f cd809b04b6ff; with env: {'TMPDIR': '/var/folders/fl/vld2l9t556d9mdw5jn4w_thh0000gn/T/', '__CF_USER_TEXT_ENCODING': '0x1F5:0x0:0x3', 'SHELL': '/usr/local/bin/zsh', 'HOME': '/Users/me', 'Apple_PubSub_Socket_Render': '/private/tmp/com.apple.launchd.ayNUuRYQoc/Render', 'SSH_AUTH_SOCK': '/private/tmp/com.apple.launchd.clyXqZhfMb/Listeners', 'PATH': '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin', 'LOGNAME': 'me', 'XPC_SERVICE_NAME': '0', 'USER': 'me', 'XPC_FLAGS': '0x0', 'LESS': '-R', 'LSCOLORS': 'Gxfxcxdxbxegedabagacad', 'NVS_HOME': '/Users/me/.nvs', 'NVS_OS': 'darwin', 'NVS_ROOT': '/Users/me/.nvs', 'NVS_USE_XZ': '1', 'OLDPWD': '/Users/me/old-pwd', 'PAGER': 'less', 'PWD': '/Users/me/new-pwd', 'SHLVL': '1', 'ZSH': '/Users/me/.oh-my-zsh', 'TERM_PROGRAM': 'vscode', 'TERM_PROGRAM_VERSION': '1.35.1', 'LANG': 'C', 'TERM': 'xterm-256color', 'LC_CTYPE': 'de_DE.UTF-8', 'TF_SHELL': 'zsh', 'TF_ALIAS': 'fuck', 'TF_SHELL_ALIASES': '-=\'cd -\'\n...=../..\n....=../../..\n.....=../../../..\n......=../../../../..\n1=\'cd -\'\n2=\'cd -2\'\n3=\'cd -3\'\n4=\'cd -4\'\n5=\'cd -5\'\n6=\'cd -6\'\n7=\'cd -7\'\n8=\'cd -8\'\n9=\'cd -9\'\nCA=\'2>&1 | cat -A\'\nG=\'| grep\'\nH=\'| head\'\nL=\'| less\'\nLL=\'2>&1 | less\'\nM=\'| most\'\nNE=\'2> /dev/null\'\nNUL=\'> /dev/null 2>&1\'\nP=\'2>&1| pygmentize -l pytb\'\nT=\'| tail\'\n_=sudo\nafind=\'ack -il\'\nbcubc=\'brew cask reinstall $(brew cask outdated) && brew cleanup\'\nbcubo=\'brew update && brew cask outdated\'\nbrewp=\'brew pin\'\nbrews=\'brew list -1\'\nbrewsp=\'brew list --pinned\'\nbubc=\'brew upgrade && brew cleanup\'\nbubo=\'brew update && brew outdated\'\nbubu=\'bubo && bubc\'\ncp=\'cp -i\'\nd=\'z denver && ./d\'\ndgulp=\'(z denver && d store gulp) || warn "Store Gulp stopped!"\'\ndsync=\'(z denver && d sync) || warn "Denver Sync stopped!"\'\ndud=\'du -d 1 -h\'\nduf=\'du -sh *\'\nfd=\'find . -type d -name\'\nff=\'find . -type f -name\'\ng=git\nga=\'git add\'\ngaa=\'git add --all\'\ngap=\'git apply\'\ngapa=\'git add --patch\'\ngau=\'git add --update\'\ngav=\'git add --verbose\'\ngb=\'git branch\'\ngbD=\'git branch -D\'\ngba=\'git branch -a\'\ngbd=\'git branch -d\'\ngbda=\'git branch --no-color --merged | command grep -vE "^(\\*|\\s*(master|develop|dev)\\s*$)" | command xargs -n 1 git branch -d\'\ngbl=\'git blame -b -w\'\ngbnm=\'git branch --no-merged\'\ngbr=\'git branch --remote\'\ngbs=\'git bisect\'\ngbsb=\'git bisect bad\'\ngbsg=\'git bisect good\'\ngbsr=\'git bisect reset\'\ngbss=\'git bisect start\'\ngc=\'git commit -v\'\n\'gc!\'=\'git commit -v --amend\'\ngca=\'git commit -v -a\'\n\'gca!\'=\'git commit -v -a --amend\'\ngcam=\'git commit -a -m\'\n\'gcan!\'=\'git commit -v -a --no-edit --amend\'\n\'gcans!\'=\'git commit -v -a -s --no-edit --amend\'\ngcb=\'git checkout -b\'\ngcd=\'git checkout develop\'\ngcf=\'git config --list\'\ngcl=\'git clone --recurse-submodules\'\ngclean=\'git clean -id\'\ngcm=\'git checkout master\'\ngcmsg=\'git commit -m\'\n\'gcn!\'=\'git commit -v --no-edit --amend\'\ngco=\'git checkout\'\ngcount=\'git shortlog -sn\'\ngcp=\'git cherry-pick\'\ngcpa=\'git cherry-pick --abort\'\ngcpc=\'git cherry-pick --continue\'\ngcs=\'git commit -S\'\ngcsm=\'git commit -s -m\'\ngd=\'git diff\'\ngdca=\'git diff --cached\'\ngdct=\'git describe --tags $(git rev-list --tags --max-count=1)\'\ngdcw=\'git diff --cached --word-diff\'\ngds=\'git diff --staged\'\ngdt=\'git diff-tree --no-commit-id --name-only -r\'\ngdw=\'git diff --word-diff\'\ngf=\'git fetch\'\ngfa=\'git fetch --all --prune\'\ngfg=\'git ls-files | grep\'\ngfo=\'git fetch origin\'\ngg=\'git gui citool\'\ngga=\'git gui citool --amend\'\nggpull=\'git pull origin "$(git_current_branch)"\'\nggpur=ggu\nggpush=\'git push origin "$(git_current_branch)"\'\nggsup=\'git branch --set-upstream-to=origin/$(git_current_branch)\'\nghh=\'git help\'\ngignore=\'git update-index --assume-unchanged\'\ngignored=\'git ls-files -v | grep "^[[:lower:]]"\'\ngit-svn-dcommit-push=\'git svn dcommit && git push github master:svntrunk\'\ngk=\'\\gitk --all --branches\'\ngke=\'\\gitk --all $(git log -g --pretty=%h)\'\ngl=\'git pull\'\nglg=\'git log --stat\'\nglgg=\'git log --graph\'\nglgga=\'git log --graph --decorate --all\'\nglgm=\'git log --graph --max-count=10\'\nglgp=\'git log --stat -p\'\nglo=\'git log --oneline --decorate\'\ngloburl=\'noglob urlglobber \'\nglod=\'git log --graph --pretty=\'\\\'\'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset\'\\\'\nglods=\'git log --graph --pretty=\'\\\'\'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset\'\\\'\' --date=short\'\nglog=\'git log --oneline --decorate --graph\'\ngloga=\'git log --oneline --decorate --graph --all\'\nglol=\'git log --graph --pretty=\'\\\'\'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\'\\\'\nglola=\'git log --graph --pretty=\'\\\'\'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\'\\\'\' --all\'\nglols=\'git log --graph --pretty=\'\\\'\'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\'\\\'\' --stat\'\nglp=_git_log_prettily\nglum=\'git pull upstream master\'\ngm=\'git merge\'\ngma=\'git merge --abort\'\ngmom=\'git merge origin/master\'\ngmt=\'git mergetool --no-prompt\'\ngmtvim=\'git mergetool --no-prompt --tool=vimdiff\'\ngmum=\'git merge upstream/master\'\ngp=\'git push\'\ngpd=\'git push --dry-run\'\ngpf=\'git push --force-with-lease\'\n\'gpf!\'=\'git push --force\'\ngpoat=\'git push origin --all && git push origin --tags\'\ngpristine=\'git reset --hard && git clean -dfx\'\ngpsup=\'git push --set-upstream origin $(git_current_branch)\'\ngpu=\'git push upstream\'\ngpv=\'git push -v\'\ngr=\'git remote\'\ngra=\'git remote add\'\ngrb=\'git rebase\'\ngrba=\'git rebase --abort\'\ngrbc=\'git rebase --continue\'\ngrbd=\'git rebase develop\'\ngrbi=\'git rebase -i\'\ngrbm=\'git rebase master\'\ngrbs=\'git rebase --skip\'\ngrep=\'grep --color\'\ngrev=\'git revert\'\ngrh=\'git reset\'\ngrhh=\'git reset --hard\'\ngrm=\'git rm\'\ngrmc=\'git rm --cached\'\ngrmv=\'git remote rename\'\ngroh=\'git reset origin/$(git_current_branch) --hard\'\ngrrm=\'git remote remove\'\ngrset=\'git remote set-url\'\ngrt=\'cd "$(git rev-parse --show-toplevel || echo .)"\'\ngru=\'git reset --\'\ngrup=\'git remote update\'\ngrv=\'git remote -v\'\ngsb=\'git status -sb\'\ngsd=\'git svn dcommit\'\ngsh=\'git show\'\ngsi=\'git submodule init\'\ngsps=\'git show --pretty=short --show-signature\'\ngsr=\'git svn rebase\'\ngss=\'git status -s\'\ngst=\'git status\'\ngsta=\'git stash push\'\ngstaa=\'git stash apply\'\ngstall=\'git stash --all\'\ngstc=\'git stash clear\'\ngstd=\'git stash drop\'\ngstl=\'git stash list\'\ngstp=\'git stash pop\'\ngsts=\'git stash show --text\'\ngsu=\'git submodule update\'\ngtl=\'gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl\'\ngts=\'git tag -s\'\ngtv=\'git tag | sort -V\'\ngunignore=\'git update-index --no-assume-unchanged\'\ngunwip=\'git log -n 1 | grep -q -c "\\-\\-wip\\-\\-" && git reset HEAD~1\'\ngup=\'git pull --rebase\'\ngupa=\'git pull --rebase --autostash\'\ngupav=\'git pull --rebase --autostash -v\'\ngupv=\'git pull --rebase -v\'\ngwch=\'git whatchanged -p --abbrev-commit --pretty=medium\'\ngwip=\'git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"\'\nh=history\nhelp=man\nhgrep=\'fc -El 0 | grep\'\nhidefiles=\'defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder\'\nhistory=omz_history\nl=\'ls -lFh\'\nlS=\'ls -1FSsh\'\nla=\'ls -lAFh\'\nlart=\'ls -1Fcart\'\nldot=\'ls -ld .*\'\nll=\'ls -l\'\nlr=\'ls -tRFh\'\nlrt=\'ls -1Fcrt\'\nls=\'ls -G\'\nlsa=\'ls -lah\'\nlt=\'ls -ltFh\'\nmd=\'mkdir -p\'\nmv=\'mv -i\'\nnpmD=\'npm i -D \'\nnpmE=\'PATH="$(npm bin)":"$PATH"\'\nnpmI=\'npm init\'\nnpmL=\'npm list\'\nnpmL0=\'npm ls --depth=0\'\nnpmO=\'npm outdated\'\nnpmP=\'npm publish\'\nnpmR=\'npm run\'\nnpmS=\'npm i -S \'\nnpmV=\'npm -v\'\nnpmg=\'npm i -g \'\nnpmst=\'npm start\'\nnpmt=\'npm test\'\nofd=\'open_command $PWD\'\np=\'ps -f\'\nrd=rmdir\nrm=\'rm -i\'\nrun-help=man\nsgrep=\'grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} \'\nshowfiles=\'defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder\'\nsortnr=\'sort -n -r\'\nt=\'tail -f\'\nunexport=unset\nvsc=\'code .\'\nvsca=\'code --add\'\nvscd=\'code --diff\'\nvscde=\'code --disable-extensions\'\nvsced=\'code --extensions-dir\'\nvscg=\'code --goto\'\nvscie=\'code --install-extension\'\nvscl=\'code --log\'\nvscn=\'code --new-window\'\nvscr=\'code --reuse-window\'\nvscu=\'code --user-data-dir\'\nvscue=\'code --uninstall-extension\'\nvscv=\'code --verbose\'\nvscw=\'code --wait\'\nwhich-command=whence\ny=yarn\nya=\'yarn add\'\nyad=\'yarn add --dev\'\nyap=\'yarn add --peer\'\nyb=\'yarn build\'\nycc=\'yarn cache clean\'\nyga=\'yarn global add\'\nygls=\'yarn global list\'\nygrm=\'yarn global remove\'\nygu=\'yarn global upgrade\'\nyh=\'yarn help\'\nyi=\'yarn init\'\nyin=\'yarn install\'\nyls=\'yarn list\'\nyout=\'yarn outdated\'\nyp=\'yarn pack\'\nyrm=\'yarn remove\'\nyrun=\'yarn run\'\nys=\'yarn serve\'\nyst=\'yarn start\'\nyt=\'yarn test\'\nyuc=\'yarn global upgrade && yarn cache clean\'\nyui=\'yarn upgrade-interactive\'\nyup=\'yarn upgrade\'\nz=\'_z 2>&1\'\nzshrc=\'${=EDITOR} ~/.zshrc\'', 'PYTHONIOENCODING': 'utf-8', 'THEFUCK_DEBUG': 'true', 'TF_HISTORY': 'which fuck\nbrew update thefuck\nfuck\nbrew upgrade thefuck\ndocker image rm -f e9b2fcd2c6ae\ndocker image ls\ndocker image rm -f cd809b04b6ff\nfuck\nfuck --version\ndocker image rm -f cd809b04b6ff', '_': '/usr/local/bin/thefuck', 'LC_ALL': 'C', 'GIT_TRACE': '1'}; is slow:  took: 0:00:00.062779
DEBUG: Importing rule: adb_unknown_command; took: 0:00:00.000618
DEBUG: Importing rule: ag_literal; took: 0:00:00.000819
DEBUG: Importing rule: apt_get; took: 0:00:00.001299
DEBUG: Importing rule: apt_get_search; took: 0:00:00.000485
DEBUG: Importing rule: apt_invalid_operation; took: 0:00:00.001241
DEBUG: Importing rule: apt_list_upgradable; took: 0:00:00.000576
DEBUG: Importing rule: apt_upgrade; took: 0:00:00.000796
DEBUG: Importing rule: aws_cli; took: 0:00:00.001182
DEBUG: Importing rule: az_cli; took: 0:00:00.000468
DEBUG: Importing rule: brew_cask_dependency; took: 0:00:00.000911
DEBUG: Importing rule: brew_install; took: 0:00:00.000268
DEBUG: Importing rule: brew_link; took: 0:00:00.000393
DEBUG: Importing rule: brew_reinstall; took: 0:00:00.000939
DEBUG: Importing rule: brew_uninstall; took: 0:00:00.000406
DEBUG: Importing rule: brew_unknown_command; took: 0:00:00.000257
DEBUG: Importing rule: brew_update_formula; took: 0:00:00.000397
DEBUG: Importing rule: cargo; took: 0:00:00.000197
DEBUG: Importing rule: cargo_no_command; took: 0:00:00.000362
DEBUG: Importing rule: cat_dir; took: 0:00:00.000492
DEBUG: Importing rule: cd_correction; took: 0:00:00.001458
DEBUG: Importing rule: cd_mkdir; took: 0:00:00.000400
DEBUG: Importing rule: cd_parent; took: 0:00:00.000387
DEBUG: Importing rule: chmod_x; took: 0:00:00.000276
DEBUG: Importing rule: composer_not_command; took: 0:00:00.000685
DEBUG: Importing rule: cp_omitting_directory; took: 0:00:00.000839
DEBUG: Importing rule: cpp11; took: 0:00:00.000531
DEBUG: Importing rule: dirty_untar; took: 0:00:00.001625
DEBUG: Importing rule: dirty_unzip; took: 0:00:00.001894
DEBUG: Importing rule: django_south_ghost; took: 0:00:00.000288
DEBUG: Importing rule: django_south_merge; took: 0:00:00.000239
DEBUG: Importing rule: dnf_no_such_command; took: 0:00:00.001135
DEBUG: Importing rule: docker_login; took: 0:00:00.000422
DEBUG: Importing rule: docker_not_command; took: 0:00:00.000826
DEBUG: Importing rule: dry; took: 0:00:00.000338
DEBUG: Importing rule: fab_command_not_found; took: 0:00:00.000539
DEBUG: Importing rule: fix_alt_space; took: 0:00:00.000494
DEBUG: Importing rule: fix_file; took: 0:00:00.002577
DEBUG: Importing rule: gem_unknown_command; took: 0:00:00.000611
DEBUG: Importing rule: git_add; took: 0:00:00.000985
DEBUG: Importing rule: git_add_force; took: 0:00:00.000501
DEBUG: Importing rule: git_bisect_usage; took: 0:00:00.000600
DEBUG: Importing rule: git_branch_delete; took: 0:00:00.000583
DEBUG: Importing rule: git_branch_exists; took: 0:00:00.000551
DEBUG: Importing rule: git_branch_list; took: 0:00:00.000354
DEBUG: Importing rule: git_checkout; took: 0:00:00.000405
DEBUG: Importing rule: git_commit_amend; took: 0:00:00.000536
DEBUG: Importing rule: git_commit_reset; took: 0:00:00.000310
DEBUG: Importing rule: git_diff_no_index; took: 0:00:00.000382
DEBUG: Importing rule: git_diff_staged; took: 0:00:00.000339
DEBUG: Importing rule: git_fix_stash; took: 0:00:00.000309
DEBUG: Importing rule: git_flag_after_filename; took: 0:00:00.000406
DEBUG: Importing rule: git_help_aliased; took: 0:00:00.000337
DEBUG: Importing rule: git_merge; took: 0:00:00.000352
DEBUG: Importing rule: git_merge_unrelated; took: 0:00:00.000341
DEBUG: Importing rule: git_not_command; took: 0:00:00.000353
DEBUG: Importing rule: git_pull; took: 0:00:00.000429
DEBUG: Importing rule: git_pull_clone; took: 0:00:00.000386
DEBUG: Importing rule: git_pull_uncommitted_changes; took: 0:00:00.000356
DEBUG: Importing rule: git_push; took: 0:00:00.000420
DEBUG: Importing rule: git_push_different_branch_names; took: 0:00:00.000387
DEBUG: Importing rule: git_push_force; took: 0:00:00.000337
DEBUG: Importing rule: git_push_pull; took: 0:00:00.000332
DEBUG: Importing rule: git_push_without_commits; took: 0:00:00.000471
DEBUG: Importing rule: git_rebase_merge_dir; took: 0:00:00.000487
DEBUG: Importing rule: git_rebase_no_changes; took: 0:00:00.000624
DEBUG: Importing rule: git_remote_delete; took: 0:00:00.000575
DEBUG: Importing rule: git_remote_seturl_add; took: 0:00:00.000675
DEBUG: Importing rule: git_rm_local_modifications; took: 0:00:00.000627
DEBUG: Importing rule: git_rm_recursive; took: 0:00:00.000432
DEBUG: Importing rule: git_rm_staged; took: 0:00:00.000471
DEBUG: Importing rule: git_stash; took: 0:00:00.000784
DEBUG: Importing rule: git_stash_pop; took: 0:00:00.000635
DEBUG: Importing rule: git_tag_force; took: 0:00:00.000415
DEBUG: Importing rule: git_two_dashes; took: 0:00:00.000348
DEBUG: Importing rule: go_run; took: 0:00:00.000310
DEBUG: Importing rule: gradle_no_task; took: 0:00:00.000552
DEBUG: Importing rule: gradle_wrapper; took: 0:00:00.000365
DEBUG: Importing rule: grep_arguments_order; took: 0:00:00.000412
DEBUG: Importing rule: grep_recursive; took: 0:00:00.000335
DEBUG: Importing rule: grunt_task_not_found; took: 0:00:00.000647
DEBUG: Importing rule: gulp_not_task; took: 0:00:00.000374
DEBUG: Importing rule: has_exists_script; took: 0:00:00.000377
DEBUG: Importing rule: heroku_multiple_apps; took: 0:00:00.000380
DEBUG: Importing rule: heroku_not_command; took: 0:00:00.000349
DEBUG: Importing rule: history; took: 0:00:00.000202
DEBUG: Importing rule: hostscli; took: 0:00:00.000533
DEBUG: Importing rule: ifconfig_device_not_found; took: 0:00:00.000412
DEBUG: Importing rule: java; took: 0:00:00.000473
DEBUG: Importing rule: javac; took: 0:00:00.000379
DEBUG: Importing rule: lein_not_task; took: 0:00:00.000477
DEBUG: Importing rule: ln_no_hard_link; took: 0:00:00.000331
DEBUG: Importing rule: ln_s_order; took: 0:00:00.000363
DEBUG: Importing rule: long_form_help; took: 0:00:00.000209
DEBUG: Importing rule: ls_all; took: 0:00:00.000647
DEBUG: Importing rule: ls_lah; took: 0:00:00.000582
DEBUG: Importing rule: man; took: 0:00:00.000787
DEBUG: Importing rule: man_no_space; took: 0:00:00.000473
DEBUG: Importing rule: mercurial; took: 0:00:00.000676
DEBUG: Importing rule: missing_space_before_subcommand; took: 0:00:00.000267
DEBUG: Importing rule: mkdir_p; took: 0:00:00.000323
DEBUG: Importing rule: mvn_no_command; took: 0:00:00.000425
DEBUG: Importing rule: mvn_unknown_lifecycle_phase; took: 0:00:00.000366
DEBUG: Importing rule: no_command; took: 0:00:00.000435
DEBUG: Importing rule: no_such_file; took: 0:00:00.000235
DEBUG: Importing rule: npm_missing_script; took: 0:00:00.000721
DEBUG: Importing rule: npm_run_script; took: 0:00:00.000397
DEBUG: Importing rule: npm_wrong_command; took: 0:00:00.000520
DEBUG: Importing rule: open; took: 0:00:00.000514
DEBUG: Importing rule: pacman; took: 0:00:00.000491
DEBUG: Importing rule: pacman_not_found; took: 0:00:00.000201
DEBUG: Importing rule: path_from_history; took: 0:00:00.000208
DEBUG: Importing rule: php_s; took: 0:00:00.000349
DEBUG: Importing rule: pip_install; took: 0:00:00.000433
DEBUG: Importing rule: pip_unknown_command; took: 0:00:00.000432
DEBUG: Importing rule: port_already_in_use; took: 0:00:00.000283
DEBUG: Importing rule: prove_recursively; took: 0:00:00.000351
DEBUG: Importing rule: pyenv_no_such_command; took: 0:00:00.000541
DEBUG: Importing rule: python_command; took: 0:00:00.000393
DEBUG: Importing rule: python_execute; took: 0:00:00.000363
DEBUG: Importing rule: quotation_marks; took: 0:00:00.000184
DEBUG: Importing rule: react_native_command_unrecognized; took: 0:00:00.000420
DEBUG: Importing rule: remove_trailing_cedilla; took: 0:00:00.000193
DEBUG: Importing rule: rm_dir; took: 0:00:00.000420
DEBUG: Importing rule: rm_root; took: 0:00:00.000379
DEBUG: Importing rule: scm_correction; took: 0:00:00.000401
DEBUG: Importing rule: sed_unterminated_s; took: 0:00:00.000824
DEBUG: Importing rule: sl_ls; took: 0:00:00.000375
DEBUG: Importing rule: ssh_known_hosts; took: 0:00:00.000780
DEBUG: Importing rule: sudo; took: 0:00:00.000399
DEBUG: Importing rule: sudo_command_from_user_path; took: 0:00:00.000734
DEBUG: Importing rule: switch_lang; took: 0:00:00.000336
DEBUG: Importing rule: systemctl; took: 0:00:00.000560
DEBUG: Importing rule: test.py; took: 0:00:00.000246
DEBUG: Importing rule: tmux; took: 0:00:00.000537
DEBUG: Importing rule: touch; took: 0:00:00.000446
DEBUG: Importing rule: tsuru_login; took: 0:00:00.000392
DEBUG: Importing rule: tsuru_not_command; took: 0:00:00.000404
DEBUG: Importing rule: unknown_command; took: 0:00:00.000260
DEBUG: Importing rule: unsudo; took: 0:00:00.000215
DEBUG: Importing rule: vagrant_up; took: 0:00:00.000397
DEBUG: Importing rule: whois; took: 0:00:00.000522
DEBUG: Importing rule: workon_doesnt_exists; took: 0:00:00.000447
DEBUG: Importing rule: yarn_alias; took: 0:00:00.000356
DEBUG: Importing rule: yarn_command_not_found; took: 0:00:00.000777
DEBUG: Importing rule: yarn_command_replaced; took: 0:00:00.000580
DEBUG: Importing rule: yarn_help; took: 0:00:00.000339
DEBUG: Trying rule: path_from_history; took: 0:00:00.000645
DEBUG: Trying rule: dry; took: 0:00:00.000114
DEBUG: Trying rule: git_stash_pop; took: 0:00:00.000041
DEBUG: Trying rule: test.py; took: 0:00:00.000004
DEBUG: Trying rule: adb_unknown_command; took: 0:00:00.000021
DEBUG: Trying rule: ag_literal; took: 0:00:00.000018
DEBUG: Trying rule: aws_cli; took: 0:00:00.000015
DEBUG: Trying rule: az_cli; took: 0:00:00.000012
DEBUG: Trying rule: brew_cask_dependency; took: 0:00:00.000013
DEBUG: Trying rule: brew_install; took: 0:00:00.000004
DEBUG: Trying rule: brew_link; took: 0:00:00.000014
DEBUG: Trying rule: brew_reinstall; took: 0:00:00.000012
DEBUG: Trying rule: brew_uninstall; took: 0:00:00.000044
DEBUG: Trying rule: brew_unknown_command; took: 0:00:00.000005
DEBUG: Trying rule: brew_update_formula; took: 0:00:00.000022
DEBUG: Trying rule: cargo; took: 0:00:00.000003
DEBUG: Trying rule: cargo_no_command; took: 0:00:00.000022
DEBUG: Trying rule: cat_dir; took: 0:00:00.000020
DEBUG: Trying rule: cd_correction; took: 0:00:00.000024
DEBUG: Trying rule: cd_mkdir; took: 0:00:00.000019
DEBUG: Trying rule: cd_parent; took: 0:00:00.000004
DEBUG: Trying rule: chmod_x; took: 0:00:00.000005
DEBUG: Trying rule: composer_not_command; took: 0:00:00.000021
DEBUG: Trying rule: cp_omitting_directory; took: 0:00:00.000030
DEBUG: Trying rule: cpp11; took: 0:00:00.000035
DEBUG: Trying rule: dirty_untar; took: 0:00:00.000038
DEBUG: Trying rule: dirty_unzip; took: 0:00:00.000021
DEBUG: Trying rule: django_south_ghost; took: 0:00:00.000005
DEBUG: Trying rule: django_south_merge; took: 0:00:00.000004
DEBUG: Trying rule: docker_login; took: 0:00:00.000027
DEBUG: Trying rule: docker_not_command; took: 0:00:00.000037
DEBUG: Trying rule: fab_command_not_found; took: 0:00:00.000020
DEBUG: Trying rule: fix_alt_space; took: 0:00:00.000007
DEBUG: Trying rule: fix_file; took: 0:00:00.000015
DEBUG: Trying rule: gem_unknown_command; took: 0:00:00.000018
DEBUG: Trying rule: git_add; took: 0:00:00.000014
DEBUG: Trying rule: git_add_force; took: 0:00:00.000013
DEBUG: Trying rule: git_bisect_usage; took: 0:00:00.000013
DEBUG: Trying rule: git_branch_delete; took: 0:00:00.000013
DEBUG: Trying rule: git_branch_exists; took: 0:00:00.000014
DEBUG: Trying rule: git_branch_list; took: 0:00:00.000012
DEBUG: Trying rule: git_checkout; took: 0:00:00.000012
DEBUG: Trying rule: git_commit_amend; took: 0:00:00.000012
DEBUG: Trying rule: git_commit_reset; took: 0:00:00.000012
DEBUG: Trying rule: git_diff_no_index; took: 0:00:00.000013
DEBUG: Trying rule: git_diff_staged; took: 0:00:00.000014
DEBUG: Trying rule: git_fix_stash; took: 0:00:00.000014
DEBUG: Trying rule: git_flag_after_filename; took: 0:00:00.000010
DEBUG: Trying rule: git_help_aliased; took: 0:00:00.000008
DEBUG: Trying rule: git_merge; took: 0:00:00.000057
DEBUG: Trying rule: git_merge_unrelated; took: 0:00:00.000042
DEBUG: Trying rule: git_not_command; took: 0:00:00.000021
DEBUG: Trying rule: git_pull; took: 0:00:00.000017
DEBUG: Trying rule: git_pull_clone; took: 0:00:00.000016
DEBUG: Trying rule: git_pull_uncommitted_changes; took: 0:00:00.000016
DEBUG: Trying rule: git_push; took: 0:00:00.000021
DEBUG: Trying rule: git_push_different_branch_names; took: 0:00:00.000012
DEBUG: Trying rule: git_push_pull; took: 0:00:00.000011
DEBUG: Trying rule: git_push_without_commits; took: 0:00:00.000010
DEBUG: Trying rule: git_rebase_merge_dir; took: 0:00:00.000011
DEBUG: Trying rule: git_rebase_no_changes; took: 0:00:00.000025
DEBUG: Trying rule: git_remote_delete; took: 0:00:00.000032
DEBUG: Trying rule: git_remote_seturl_add; took: 0:00:00.000014
DEBUG: Trying rule: git_rm_local_modifications; took: 0:00:00.000009
DEBUG: Trying rule: git_rm_recursive; took: 0:00:00.000009
DEBUG: Trying rule: git_rm_staged; took: 0:00:00.000009
DEBUG: Trying rule: git_stash; took: 0:00:00.000009
DEBUG: Trying rule: git_tag_force; took: 0:00:00.000009
DEBUG: Trying rule: git_two_dashes; took: 0:00:00.000009
DEBUG: Trying rule: go_run; took: 0:00:00.000019
DEBUG: Trying rule: gradle_no_task; took: 0:00:00.000020
DEBUG: Trying rule: gradle_wrapper; took: 0:00:00.000015
DEBUG: Trying rule: grep_arguments_order; took: 0:00:00.000013
DEBUG: Trying rule: grep_recursive; took: 0:00:00.000010
DEBUG: Trying rule: grunt_task_not_found; took: 0:00:00.000010
DEBUG: Trying rule: gulp_not_task; took: 0:00:00.000010
DEBUG: Trying rule: has_exists_script; took: 0:00:00.000026
DEBUG: Trying rule: heroku_multiple_apps; took: 0:00:00.000011
DEBUG: Trying rule: heroku_not_command; took: 0:00:00.000009
DEBUG: Trying rule: hostscli; took: 0:00:00.000013
DEBUG: Trying rule: ifconfig_device_not_found; took: 0:00:00.000011
DEBUG: Trying rule: java; took: 0:00:00.000010
DEBUG: Trying rule: javac; took: 0:00:00.000011
DEBUG: Trying rule: lein_not_task; took: 0:00:00.000011
DEBUG: Trying rule: ln_no_hard_link; took: 0:00:00.000004
DEBUG: Trying rule: ln_s_order; took: 0:00:00.000003
DEBUG: Trying rule: ls_all; took: 0:00:00.000016
DEBUG: Trying rule: ls_lah; took: 0:00:00.000009
DEBUG: Trying rule: man; took: 0:00:00.000021
DEBUG: Trying rule: mercurial; took: 0:00:00.000010
DEBUG: Trying rule: mkdir_p; took: 0:00:00.000003
DEBUG: Trying rule: mvn_no_command; took: 0:00:00.000010
DEBUG: Trying rule: mvn_unknown_lifecycle_phase; took: 0:00:00.000009
DEBUG: Trying rule: no_such_file; took: 0:00:00.000685
DEBUG: Trying rule: npm_missing_script; took: 0:00:00.000034
DEBUG: Trying rule: npm_run_script; took: 0:00:00.000026
DEBUG: Trying rule: npm_wrong_command; took: 0:00:00.000010
DEBUG: Trying rule: open; took: 0:00:00.000012
DEBUG: Trying rule: php_s; took: 0:00:00.000011
DEBUG: Trying rule: pip_install; took: 0:00:00.000012
DEBUG: Trying rule: pip_unknown_command; took: 0:00:00.000011
DEBUG: Trying rule: port_already_in_use; took: 0:00:00.000584
DEBUG: Trying rule: prove_recursively; took: 0:00:00.000017
DEBUG: Trying rule: pyenv_no_such_command; took: 0:00:00.000011
DEBUG: Trying rule: python_command; took: 0:00:00.000005
DEBUG: Trying rule: python_execute; took: 0:00:00.000012
DEBUG: Trying rule: quotation_marks; took: 0:00:00.000002
DEBUG: Trying rule: react_native_command_unrecognized; took: 0:00:00.000010
DEBUG: Trying rule: remove_trailing_cedilla; took: 0:00:00.000002
DEBUG: Trying rule: rm_dir; took: 0:00:00.000005
DEBUG: Trying rule: scm_correction; took: 0:00:00.000013
DEBUG: Trying rule: sed_unterminated_s; took: 0:00:00.000010
DEBUG: Trying rule: sl_ls; took: 0:00:00.000002
DEBUG: Trying rule: ssh_known_hosts; took: 0:00:00.000009
DEBUG: Trying rule: sudo; took: 0:00:00.000011
DEBUG: Trying rule: sudo_command_from_user_path; took: 0:00:00.000010
DEBUG: Trying rule: switch_lang; took: 0:00:00.000002
DEBUG: Trying rule: systemctl; took: 0:00:00.000011
DEBUG: Trying rule: tmux; took: 0:00:00.000010
DEBUG: Trying rule: touch; took: 0:00:00.000009
DEBUG: Trying rule: tsuru_login; took: 0:00:00.000012
DEBUG: Trying rule: tsuru_not_command; took: 0:00:00.000008
DEBUG: Trying rule: unknown_command; took: 0:00:00.000329
DEBUG: Trying rule: unsudo; took: 0:00:00.000018
DEBUG: Trying rule: vagrant_up; took: 0:00:00.000015
DEBUG: Trying rule: whois; took: 0:00:00.000012
DEBUG: Trying rule: workon_doesnt_exists; took: 0:00:00.000024
DEBUG: Trying rule: yarn_alias; took: 0:00:00.000010
DEBUG: Trying rule: yarn_command_not_found; took: 0:00:00.000009
DEBUG: Trying rule: yarn_command_replaced; took: 0:00:00.000009
DEBUG: Trying rule: yarn_help; took: 0:00:00.000009
DEBUG: Trying rule: man_no_space; took: 0:00:00.000002
DEBUG: Trying rule: no_command; took: 0:00:00.000007
DEBUG: Trying rule: missing_space_before_subcommand; took: 0:00:00.000005
DEBUG: Trying rule: long_form_help; took: 0:00:00.000337
DEBUG: Trying rule: history; took: 0:00:00.018970
docker image rm -f e9b2fcd2c6ae [enter/↑/↓/ctrl+c]
```

</details>

If the bug only appears with a specific application, the output of that application and its version:

    Docker version 18.09.2, build 6247962

Anything else you think is relevant:

`docker image rm -f abcdef` already gives the hint that a container depends on the image, that shall be removed. I can imagine that `fuck` stops and removes the container first, by parsing the container id from the output.

Example usage:

```bash
$ docker image rm -f cd809b04b6ff
Error response from daemon: conflict: unable to delete cd809b04b6ff (cannot be forced) - image is being used by running container e5e2591040d1
$ fuck
docker container rm -f e5e2591040d1 && docker image rm -f cd809b04b6ff [enter/↑/↓/ctrl+c]
```

<!-- It's only with enough information that we can do something to fix the problem. -->



Discussion:
Hey! There's no such rule. Would you like to add it?
Tried to fix this in https://github.com/nvbn/thefuck/pull/928



Patch:
diff --git a/README.md b/README.md
index d9424dfd2..838300762 100644
--- a/README.md
+++ b/README.md
@@ -191,6 +191,7 @@ following rules are enabled by default:
 * `django_south_merge` &ndash; adds `--merge` to inconsistent django south migration;
 * `docker_login` &ndash; executes a `docker login` and repeats the previous command;
 * `docker_not_command` &ndash; fixes wrong docker commands like `docker tags`;
+* `docker_image_being_used_by_container` &dash; removes the container that is using the image before removing the image;
 * `dry` &ndash; fixes repetitions like `git git push`;
 * `fab_command_not_found` &ndash; fix misspelled fabric commands;
 * `fix_alt_space` &ndash; replaces Alt+Space with Space character;
diff --git a/thefuck/rules/docker_image_being_used_by_container.py b/thefuck/rules/docker_image_being_used_by_container.py
new file mode 100644
index 000000000..d68f9192d
--- /dev/null
+++ b/thefuck/rules/docker_image_being_used_by_container.py
@@ -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)


Test patch:
diff --git a/tests/rules/test_docker_image_being_used_by_container.py b/tests/rules/test_docker_image_being_used_by_container.py
new file mode 100644
index 000000000..00d9e6742
--- /dev/null
+++ b/tests/rules/test_docker_image_being_used_by_container.py
@@ -0,0 +1,27 @@
+from thefuck.rules.docker_image_being_used_by_container import match, get_new_command
+from thefuck.types import Command
+
+
+def test_match():
+    err_response = """Error response from daemon: conflict: unable to delete cd809b04b6ff (cannot be forced) - image is being used by running container e5e2591040d1"""
+    assert match(Command('docker image rm -f cd809b04b6ff', err_response))
+
+
+def test_not_match():
+    err_response = 'bash: docker: command not found'
+    assert not match(Command('docker image rm -f cd809b04b6ff', err_response))
+
+
+def test_not_docker_command():
+    err_response = """Error response from daemon: conflict: unable to delete cd809b04b6ff (cannot be forced) - image is being used by running container e5e2591040d1"""
+    assert not match(Command('git image rm -f cd809b04b6ff', err_response))
+
+
+def test_get_new_command():
+    err_response = """
+        Error response from daemon: conflict: unable to delete cd809b04b6ff (cannot be forced) - image
+        is being used by running container e5e2591040d1
+        """
+    result = get_new_command(Command('docker image rm -f cd809b04b6ff', err_response))
+    expected = 'docker container rm -f e5e2591040d1 && docker image rm -f cd809b04b6ff'
+    assert result == expected