How do i delete all docker containers?



  • Note: You only want to do this if you're in testing or development, generally not a good idea to run these command in live/prod environments, but you knew that already?

    Delete all containers

    $ docker rm $(docker ps -a -q)
    

    docker rm is the usual command to remove containers, The $(docker ps -a -q) provides list of container ids to remove.

    For example, correct input for our original command.

    $ docker ps -a -q       
    b26ec3bc4816
    

    Take the -q for quite off and you get this. not the right input for our initial command.

    $ docker ps -a   
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
    b26ec3bc4816        hello-world         "/hello"            9 seconds ago       Exited (0) 8 seconds ago                       unruffled_jang
    

Log in to reply
 

© Lightnetics 2024