github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/docs/reference/commandline/rm.md (about) 1 <!--[metadata]> 2 +++ 3 title = "rm" 4 description = "The rm command description and usage" 5 keywords = ["remove, Docker, container"] 6 [menu.main] 7 parent = "smn_cli" 8 +++ 9 <![end-metadata]--> 10 11 # rm 12 13 Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...] 14 15 Remove one or more containers 16 17 -f, --force Force the removal of a running container (uses SIGKILL) 18 --help Print usage 19 -l, --link Remove the specified link 20 -v, --volumes Remove the volumes associated with the container 21 22 ## Examples 23 24 $ docker rm /redis 25 /redis 26 27 This will remove the container referenced under the link 28 `/redis`. 29 30 $ docker rm --link /webapp/redis 31 /webapp/redis 32 33 This will remove the underlying link between `/webapp` and the `/redis` 34 containers removing all network communication. 35 36 $ docker rm --force redis 37 redis 38 39 The main process inside the container referenced under the link `/redis` will receive 40 `SIGKILL`, then the container will be removed. 41 42 $ docker rm $(docker ps -a -q) 43 44 This command will delete all stopped containers. The command 45 `docker ps -a -q` will return all existing container IDs and pass them to 46 the `rm` command which will delete them. Any running containers will not be 47 deleted. 48 49 $ docker rm -v redis 50 redis 51 52 This command will remove the container and any volumes associated with it. 53 Note that if a volume was specified with a name, it will not be removed. 54 55 $ docker create -v awesome:/foo -v /bar --name hello redis 56 hello 57 $ docker rm -v hello 58 59 In this example, the volume for `/foo` will remain intact, but the volume for 60 `/bar` will be removed. The same behavior holds for volumes inherited with 61 `--volumes-from`.