To remove the container from the host, we use the docker rm command. The syntax is as follows:
$ docker rm [OPTIONS] CONTAINER [CONTAINER...]
You can specify a single container or more containers at once. If you are running short-term foreground processes over and over many times, these file systems can grow rapidly in size. There's a solution for that: instead of cleaning manually by hand, tell Docker to automatically clean up the container and remove the file system when the container exits. You do this by adding the --rm flag, so that the container data is removed automatically after the process has finished.
For example, use the run command ...