You may received an Error response from daemon: You cannot remove a running container [CONTAINER_ID] Stop the container before attempting removal or force remove when you trying to remove the running container in Docker.
$ docker container rm 2cf e43 9a5
Error response from daemon: You cannot remove a running container 2cfe439a588bb40ceb91800b8d9a3ba25823b29b3644a52602a40619faca49bb. Stop the container before attempting removal or force remove
Just look at the docker container remove option using the --help option,
$ docker container rm --help
Usage: docker container rm [OPTIONS] CONTAINER [CONTAINER...]
Remove one or more containers
Options:
-f, --force Force the removal of a running container (uses SIGKILL)
-l, --link Remove the specified link
-v, --volumes Remove anonymous volumes associated with the container
So, using the -f or --force option in rm Force the removal of a running container.
$ docker container rm -f 2cfe439a5
Comments (0)