Skip to content

Instantly share code, notes, and snippets.

@hitaboy
Last active September 14, 2018 20:56
Show Gist options
  • Save hitaboy/3c59b24524aee52b628a11d301775f83 to your computer and use it in GitHub Desktop.
Save hitaboy/3c59b24524aee52b628a11d301775f83 to your computer and use it in GitHub Desktop.
Docker containers cleaning

You find it stopped

docker ps -a

You can simply start it using below command:

docker start webserver

EDIT: Alternatives If you want to start the container with below command each time,

docker run -d -p 80:80 --name webserver nginx

then use one of the following:

method 1: use --rm switch i.e., container gets destroyed automatically as soon as it is stopped

docker run -d -p 80:80 --rm --name webserver nginx

method 2: remove it explicitly after stopping the container before starting the command that you are currently using.

docker stop <container name>
docker rm <container name>

remove all containers

docker rm $(docker ps -a -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment