Figure 13-27 Custom Content Shared from the Local
Host
To stop running a container, you use the stop or kill
command. The difference between the two is pretty
obvious. stop tries to allow the container time to finish
any final work in a graceful way. Using kill, on the other
hand, is like pulling the plug. For most situations, you
want to use stop:
Click here to view code image
$ docker container stop test-nginx
test-nginx
stop and kill both halt the container but don’t remove it
from memory. If you type docker container ls -a, you
will still see it listed. When you want to remove the
container from memory, you can use the rm command.
You can also use the very handy command prune to
remove all halted containers from memory. This is useful
on a laptop when you’re testing containers and want to
free up memory without having to individually remove
multiple containers. Just be careful not to get rid of any
container you might actually want to start back up
because prune will get rid of every inactive container.
Here is an example of prune in action: