How to list containers in Docker












760














There's a command to list images, docker images, but there doesn't seem to be a corresponding docker containers.



Other than becoming root and looking into /var/lib/docker there doesn't seem a way to do that. Am I missing something? Is that something one isn't supposed to do?










share|improve this question
























  • Similar question on Stack Overflow stackoverflow.com/questions/38464549/…
    – Yogesh Darji
    Aug 29 '17 at 16:25
















760














There's a command to list images, docker images, but there doesn't seem to be a corresponding docker containers.



Other than becoming root and looking into /var/lib/docker there doesn't seem a way to do that. Am I missing something? Is that something one isn't supposed to do?










share|improve this question
























  • Similar question on Stack Overflow stackoverflow.com/questions/38464549/…
    – Yogesh Darji
    Aug 29 '17 at 16:25














760












760








760


140





There's a command to list images, docker images, but there doesn't seem to be a corresponding docker containers.



Other than becoming root and looking into /var/lib/docker there doesn't seem a way to do that. Am I missing something? Is that something one isn't supposed to do?










share|improve this question















There's a command to list images, docker images, but there doesn't seem to be a corresponding docker containers.



Other than becoming root and looking into /var/lib/docker there doesn't seem a way to do that. Am I missing something? Is that something one isn't supposed to do?







docker






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 21 '18 at 19:58









Peter Mortensen

13.5k1983111




13.5k1983111










asked May 30 '13 at 15:41









w00t

7,95153348




7,95153348












  • Similar question on Stack Overflow stackoverflow.com/questions/38464549/…
    – Yogesh Darji
    Aug 29 '17 at 16:25


















  • Similar question on Stack Overflow stackoverflow.com/questions/38464549/…
    – Yogesh Darji
    Aug 29 '17 at 16:25
















Similar question on Stack Overflow stackoverflow.com/questions/38464549/…
– Yogesh Darji
Aug 29 '17 at 16:25




Similar question on Stack Overflow stackoverflow.com/questions/38464549/…
– Yogesh Darji
Aug 29 '17 at 16:25












12 Answers
12






active

oldest

votes


















1285














To show only running containers use the given command:



docker ps


To show all containers use the given command:



docker ps -a


To show the latest created container (includes all states) use the given command:



docker ps -l


To show n last created containers (includes all states) use the given command:



docker ps -n=-1


To display total file sizes use the given command:



docker ps -s


The content presented above is from docker.com.



In the new version of Docker, commands are updated, and some management commands are added:



docker container ls


Is used to list all the running containers.



docker container ls -a


Is used to list all the containers created irrespective of its state.



Here container is the management command.






share|improve this answer



















  • 112




    And then, if you want to clean them all: docker rm `docker ps -aq`
    – cregox
    Nov 13 '15 at 20:28








  • 1




    I looked at the "docker ps -a", and list out about 10 docker name to remove one by one. After finish removal, come back and see your comment (cwl)
    – lean
    Oct 26 '16 at 10:28






  • 8




    Also for folks curious about an alternate form of command substitution @cregox's oneliner can be rewritten as docker rm $(docker ps -aq)
    – mbigras
    Feb 25 '17 at 6:00










  • @RutgerHofste both commands (docker rm and docker ps) do show up in docker's help.
    – Munchkin
    Oct 16 '17 at 12:28






  • 4




    Another helpful way to clean all unnecessary items like dangling containers, unused images, logs etc is by using docker system prune --all. You can find the docker documentation here
    – Arun Thundyill Saseendran
    Oct 19 '17 at 14:42





















118














To list all running and stopped containers



docker ps -a


To list all running containers (just stating the obvious and also example use of -f filtering option)



docker ps -a -f status=running


To list all running and stopped containers, showing only their container id



docker ps -aq


To remove all containers that are NOT running



docker rm `docker ps -aq -f status=exited`





share|improve this answer





























    28














    Note that some time ago there was an update to this command. It will not show the container size by default (since this is rather expensive for many running containers). Use docker ps -s to display container size as well.






    share|improve this answer





















    • As per mrh's answer below, you will also need the -a switch to view containers that are not running (likely to be the case for those you'd like to remove), so the final command is docker ps -as (don't forget to prepend sudo if the daemon is running as root)
      – Anthony DiSanti
      Apr 19 '16 at 23:56





















    17














    docker ps -s will show the size of running containers only.



    To check the size of all containers use docker ps -as






    share|improve this answer





























      13














      To list only the containers SHA1:



      docker ps -aq --no-trunc


      That way, you can use the list of all containers for other commands (which accept multiple container ids as parameters).



      For example, to list only the name of all containers (since docker ps list only their names with other information):



      docker inspect --format='{{.Name}}' $(sudo docker ps -aq --no-trunc)





      share|improve this answer





























        12














        There are also the following options:



        docker container ls
        docker container ls -a
        # --all, -a
        # Show all containers (default shows just running)


        since: 1.13.0 (2017-01-18):




        Restructure CLI commands by adding docker image and docker container commands for more consistency #26025




        and as stated here: Introducing Docker 1.13, users are encouraged to adopt the new syntax:




        CLI restructured



        In Docker 1.13, we regrouped every command to sit under the logical object it’s interacting with. For example list and start of containers are now subcommands of docker container and history is a subcommand of docker image.



        These changes let us clean up the Docker CLI syntax, improve help text and make Docker simpler to use. The old command syntax is still supported, but we encourage everybody to adopt the new syntax.







        share|improve this answer



















        • 1




          great info, a shame that docker --help has the suggested interface 3 pages back in its output, hidden before the deprecated commands!
          – danio
          Mar 8 '18 at 10:07



















        4














        The Docker command set is simple and holds together well:



        docker stack ls
        docker service ls
        docker image ls
        docker container ls


        Teaching the aliases first is confusing. Once you understand what's going on, they can save some keystrokes:



        docker images -> docker image ls
        docker ps -> docker container ls
        docker rmi -> docker image rm
        docker rm -> docker container rm


        There are several aliases in Docker. For instance:



        docker rmi
        docker image rm
        docker image rmi
        docker image remove


        are all the same command (see for your self using docker help image rm).






        share|improve this answer































          0














          I got the error message Cannot connect to the Docker daemon. I forgot I am running the daemon as root and needed sudo:



          $ sudo docker ps





          share|improve this answer



















          • 1




            alias docker="sudo --group docker docker"
            – ctrl-alt-delor
            Feb 13 '17 at 18:15





















          0














          Command to get all containers ::



          docker ps -a


          Command to get running container::



          docker ps





          share|improve this answer





























            0














            There are many ways to list all containers.




            You can find using 3 Aliasesls, ps, list like this.




            sudo docker container ls 
            sudo docker container ps
            sudo docker container list
            sudo docker ps
            sudo docker ps -a


            You can also use give option[option].



            Options -:



              -a, --all             Show all containers (default shows just running)
            -f, --filter filter Filter output based on conditions provided
            --format string Pretty-print containers using a Go template
            -n, --last int Show last created containers (includes all states) (default -1)
            -l, --latest Show the latest created container (includes all states)
            --no-trunc Don't truncate output
            -q, --quiet Only display numeric IDs
            -s, --size Display total file sizes


            You can use an option like this:



            sudo docker ps //Showing only running containers
            sudo docker ps -a //All container (running + stopped)
            sudo docker pa -l // latest
            sudo docker ps -n <int valuse 1,2,3 etc>// latest number of created containers
            sudo docker ps -s // Display container with size
            sudo docker ps -q // Only display numeric IDs for containers
            docker docker ps -a | tail -n 1 //oldest container





            share|improve this answer































              -1














              docker ps [OPTIONS]


              Following command will show only running containers by default.



              docker ps


              To see all containers:



              docker ps -a


              For showing the latest created container:



              docker ps -l





              share|improve this answer































                -2














                It is always recommended to add the user in a Docker group.



                That can be done like:



                sudo groupadd docker
                sudo usermod -aG docker $USER --> Equivalent to this you can add the user
                in /etc/passwd manually.





                share|improve this answer























                • Hey any one help me with docker
                  – harkesh kumar
                  Nov 19 '18 at 12:31











                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16840409%2fhow-to-list-containers-in-docker%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                12 Answers
                12






                active

                oldest

                votes








                12 Answers
                12






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                1285














                To show only running containers use the given command:



                docker ps


                To show all containers use the given command:



                docker ps -a


                To show the latest created container (includes all states) use the given command:



                docker ps -l


                To show n last created containers (includes all states) use the given command:



                docker ps -n=-1


                To display total file sizes use the given command:



                docker ps -s


                The content presented above is from docker.com.



                In the new version of Docker, commands are updated, and some management commands are added:



                docker container ls


                Is used to list all the running containers.



                docker container ls -a


                Is used to list all the containers created irrespective of its state.



                Here container is the management command.






                share|improve this answer



















                • 112




                  And then, if you want to clean them all: docker rm `docker ps -aq`
                  – cregox
                  Nov 13 '15 at 20:28








                • 1




                  I looked at the "docker ps -a", and list out about 10 docker name to remove one by one. After finish removal, come back and see your comment (cwl)
                  – lean
                  Oct 26 '16 at 10:28






                • 8




                  Also for folks curious about an alternate form of command substitution @cregox's oneliner can be rewritten as docker rm $(docker ps -aq)
                  – mbigras
                  Feb 25 '17 at 6:00










                • @RutgerHofste both commands (docker rm and docker ps) do show up in docker's help.
                  – Munchkin
                  Oct 16 '17 at 12:28






                • 4




                  Another helpful way to clean all unnecessary items like dangling containers, unused images, logs etc is by using docker system prune --all. You can find the docker documentation here
                  – Arun Thundyill Saseendran
                  Oct 19 '17 at 14:42


















                1285














                To show only running containers use the given command:



                docker ps


                To show all containers use the given command:



                docker ps -a


                To show the latest created container (includes all states) use the given command:



                docker ps -l


                To show n last created containers (includes all states) use the given command:



                docker ps -n=-1


                To display total file sizes use the given command:



                docker ps -s


                The content presented above is from docker.com.



                In the new version of Docker, commands are updated, and some management commands are added:



                docker container ls


                Is used to list all the running containers.



                docker container ls -a


                Is used to list all the containers created irrespective of its state.



                Here container is the management command.






                share|improve this answer



















                • 112




                  And then, if you want to clean them all: docker rm `docker ps -aq`
                  – cregox
                  Nov 13 '15 at 20:28








                • 1




                  I looked at the "docker ps -a", and list out about 10 docker name to remove one by one. After finish removal, come back and see your comment (cwl)
                  – lean
                  Oct 26 '16 at 10:28






                • 8




                  Also for folks curious about an alternate form of command substitution @cregox's oneliner can be rewritten as docker rm $(docker ps -aq)
                  – mbigras
                  Feb 25 '17 at 6:00










                • @RutgerHofste both commands (docker rm and docker ps) do show up in docker's help.
                  – Munchkin
                  Oct 16 '17 at 12:28






                • 4




                  Another helpful way to clean all unnecessary items like dangling containers, unused images, logs etc is by using docker system prune --all. You can find the docker documentation here
                  – Arun Thundyill Saseendran
                  Oct 19 '17 at 14:42
















                1285












                1285








                1285






                To show only running containers use the given command:



                docker ps


                To show all containers use the given command:



                docker ps -a


                To show the latest created container (includes all states) use the given command:



                docker ps -l


                To show n last created containers (includes all states) use the given command:



                docker ps -n=-1


                To display total file sizes use the given command:



                docker ps -s


                The content presented above is from docker.com.



                In the new version of Docker, commands are updated, and some management commands are added:



                docker container ls


                Is used to list all the running containers.



                docker container ls -a


                Is used to list all the containers created irrespective of its state.



                Here container is the management command.






                share|improve this answer














                To show only running containers use the given command:



                docker ps


                To show all containers use the given command:



                docker ps -a


                To show the latest created container (includes all states) use the given command:



                docker ps -l


                To show n last created containers (includes all states) use the given command:



                docker ps -n=-1


                To display total file sizes use the given command:



                docker ps -s


                The content presented above is from docker.com.



                In the new version of Docker, commands are updated, and some management commands are added:



                docker container ls


                Is used to list all the running containers.



                docker container ls -a


                Is used to list all the containers created irrespective of its state.



                Here container is the management command.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jun 21 '18 at 19:59









                Peter Mortensen

                13.5k1983111




                13.5k1983111










                answered May 30 '13 at 17:15









                vieux

                16.1k32124




                16.1k32124








                • 112




                  And then, if you want to clean them all: docker rm `docker ps -aq`
                  – cregox
                  Nov 13 '15 at 20:28








                • 1




                  I looked at the "docker ps -a", and list out about 10 docker name to remove one by one. After finish removal, come back and see your comment (cwl)
                  – lean
                  Oct 26 '16 at 10:28






                • 8




                  Also for folks curious about an alternate form of command substitution @cregox's oneliner can be rewritten as docker rm $(docker ps -aq)
                  – mbigras
                  Feb 25 '17 at 6:00










                • @RutgerHofste both commands (docker rm and docker ps) do show up in docker's help.
                  – Munchkin
                  Oct 16 '17 at 12:28






                • 4




                  Another helpful way to clean all unnecessary items like dangling containers, unused images, logs etc is by using docker system prune --all. You can find the docker documentation here
                  – Arun Thundyill Saseendran
                  Oct 19 '17 at 14:42
















                • 112




                  And then, if you want to clean them all: docker rm `docker ps -aq`
                  – cregox
                  Nov 13 '15 at 20:28








                • 1




                  I looked at the "docker ps -a", and list out about 10 docker name to remove one by one. After finish removal, come back and see your comment (cwl)
                  – lean
                  Oct 26 '16 at 10:28






                • 8




                  Also for folks curious about an alternate form of command substitution @cregox's oneliner can be rewritten as docker rm $(docker ps -aq)
                  – mbigras
                  Feb 25 '17 at 6:00










                • @RutgerHofste both commands (docker rm and docker ps) do show up in docker's help.
                  – Munchkin
                  Oct 16 '17 at 12:28






                • 4




                  Another helpful way to clean all unnecessary items like dangling containers, unused images, logs etc is by using docker system prune --all. You can find the docker documentation here
                  – Arun Thundyill Saseendran
                  Oct 19 '17 at 14:42










                112




                112




                And then, if you want to clean them all: docker rm `docker ps -aq`
                – cregox
                Nov 13 '15 at 20:28






                And then, if you want to clean them all: docker rm `docker ps -aq`
                – cregox
                Nov 13 '15 at 20:28






                1




                1




                I looked at the "docker ps -a", and list out about 10 docker name to remove one by one. After finish removal, come back and see your comment (cwl)
                – lean
                Oct 26 '16 at 10:28




                I looked at the "docker ps -a", and list out about 10 docker name to remove one by one. After finish removal, come back and see your comment (cwl)
                – lean
                Oct 26 '16 at 10:28




                8




                8




                Also for folks curious about an alternate form of command substitution @cregox's oneliner can be rewritten as docker rm $(docker ps -aq)
                – mbigras
                Feb 25 '17 at 6:00




                Also for folks curious about an alternate form of command substitution @cregox's oneliner can be rewritten as docker rm $(docker ps -aq)
                – mbigras
                Feb 25 '17 at 6:00












                @RutgerHofste both commands (docker rm and docker ps) do show up in docker's help.
                – Munchkin
                Oct 16 '17 at 12:28




                @RutgerHofste both commands (docker rm and docker ps) do show up in docker's help.
                – Munchkin
                Oct 16 '17 at 12:28




                4




                4




                Another helpful way to clean all unnecessary items like dangling containers, unused images, logs etc is by using docker system prune --all. You can find the docker documentation here
                – Arun Thundyill Saseendran
                Oct 19 '17 at 14:42






                Another helpful way to clean all unnecessary items like dangling containers, unused images, logs etc is by using docker system prune --all. You can find the docker documentation here
                – Arun Thundyill Saseendran
                Oct 19 '17 at 14:42















                118














                To list all running and stopped containers



                docker ps -a


                To list all running containers (just stating the obvious and also example use of -f filtering option)



                docker ps -a -f status=running


                To list all running and stopped containers, showing only their container id



                docker ps -aq


                To remove all containers that are NOT running



                docker rm `docker ps -aq -f status=exited`





                share|improve this answer


























                  118














                  To list all running and stopped containers



                  docker ps -a


                  To list all running containers (just stating the obvious and also example use of -f filtering option)



                  docker ps -a -f status=running


                  To list all running and stopped containers, showing only their container id



                  docker ps -aq


                  To remove all containers that are NOT running



                  docker rm `docker ps -aq -f status=exited`





                  share|improve this answer
























                    118












                    118








                    118






                    To list all running and stopped containers



                    docker ps -a


                    To list all running containers (just stating the obvious and also example use of -f filtering option)



                    docker ps -a -f status=running


                    To list all running and stopped containers, showing only their container id



                    docker ps -aq


                    To remove all containers that are NOT running



                    docker rm `docker ps -aq -f status=exited`





                    share|improve this answer












                    To list all running and stopped containers



                    docker ps -a


                    To list all running containers (just stating the obvious and also example use of -f filtering option)



                    docker ps -a -f status=running


                    To list all running and stopped containers, showing only their container id



                    docker ps -aq


                    To remove all containers that are NOT running



                    docker rm `docker ps -aq -f status=exited`






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Apr 12 '16 at 6:37









                    kramfs

                    1,401196




                    1,401196























                        28














                        Note that some time ago there was an update to this command. It will not show the container size by default (since this is rather expensive for many running containers). Use docker ps -s to display container size as well.






                        share|improve this answer





















                        • As per mrh's answer below, you will also need the -a switch to view containers that are not running (likely to be the case for those you'd like to remove), so the final command is docker ps -as (don't forget to prepend sudo if the daemon is running as root)
                          – Anthony DiSanti
                          Apr 19 '16 at 23:56


















                        28














                        Note that some time ago there was an update to this command. It will not show the container size by default (since this is rather expensive for many running containers). Use docker ps -s to display container size as well.






                        share|improve this answer





















                        • As per mrh's answer below, you will also need the -a switch to view containers that are not running (likely to be the case for those you'd like to remove), so the final command is docker ps -as (don't forget to prepend sudo if the daemon is running as root)
                          – Anthony DiSanti
                          Apr 19 '16 at 23:56
















                        28












                        28








                        28






                        Note that some time ago there was an update to this command. It will not show the container size by default (since this is rather expensive for many running containers). Use docker ps -s to display container size as well.






                        share|improve this answer












                        Note that some time ago there was an update to this command. It will not show the container size by default (since this is rather expensive for many running containers). Use docker ps -s to display container size as well.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jul 30 '13 at 11:29









                        qkrijger

                        15k62734




                        15k62734












                        • As per mrh's answer below, you will also need the -a switch to view containers that are not running (likely to be the case for those you'd like to remove), so the final command is docker ps -as (don't forget to prepend sudo if the daemon is running as root)
                          – Anthony DiSanti
                          Apr 19 '16 at 23:56




















                        • As per mrh's answer below, you will also need the -a switch to view containers that are not running (likely to be the case for those you'd like to remove), so the final command is docker ps -as (don't forget to prepend sudo if the daemon is running as root)
                          – Anthony DiSanti
                          Apr 19 '16 at 23:56


















                        As per mrh's answer below, you will also need the -a switch to view containers that are not running (likely to be the case for those you'd like to remove), so the final command is docker ps -as (don't forget to prepend sudo if the daemon is running as root)
                        – Anthony DiSanti
                        Apr 19 '16 at 23:56






                        As per mrh's answer below, you will also need the -a switch to view containers that are not running (likely to be the case for those you'd like to remove), so the final command is docker ps -as (don't forget to prepend sudo if the daemon is running as root)
                        – Anthony DiSanti
                        Apr 19 '16 at 23:56













                        17














                        docker ps -s will show the size of running containers only.



                        To check the size of all containers use docker ps -as






                        share|improve this answer


























                          17














                          docker ps -s will show the size of running containers only.



                          To check the size of all containers use docker ps -as






                          share|improve this answer
























                            17












                            17








                            17






                            docker ps -s will show the size of running containers only.



                            To check the size of all containers use docker ps -as






                            share|improve this answer












                            docker ps -s will show the size of running containers only.



                            To check the size of all containers use docker ps -as







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Dec 13 '14 at 13:01









                            mrh

                            33927




                            33927























                                13














                                To list only the containers SHA1:



                                docker ps -aq --no-trunc


                                That way, you can use the list of all containers for other commands (which accept multiple container ids as parameters).



                                For example, to list only the name of all containers (since docker ps list only their names with other information):



                                docker inspect --format='{{.Name}}' $(sudo docker ps -aq --no-trunc)





                                share|improve this answer


























                                  13














                                  To list only the containers SHA1:



                                  docker ps -aq --no-trunc


                                  That way, you can use the list of all containers for other commands (which accept multiple container ids as parameters).



                                  For example, to list only the name of all containers (since docker ps list only their names with other information):



                                  docker inspect --format='{{.Name}}' $(sudo docker ps -aq --no-trunc)





                                  share|improve this answer
























                                    13












                                    13








                                    13






                                    To list only the containers SHA1:



                                    docker ps -aq --no-trunc


                                    That way, you can use the list of all containers for other commands (which accept multiple container ids as parameters).



                                    For example, to list only the name of all containers (since docker ps list only their names with other information):



                                    docker inspect --format='{{.Name}}' $(sudo docker ps -aq --no-trunc)





                                    share|improve this answer












                                    To list only the containers SHA1:



                                    docker ps -aq --no-trunc


                                    That way, you can use the list of all containers for other commands (which accept multiple container ids as parameters).



                                    For example, to list only the name of all containers (since docker ps list only their names with other information):



                                    docker inspect --format='{{.Name}}' $(sudo docker ps -aq --no-trunc)






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered May 6 '15 at 7:50









                                    VonC

                                    830k28926113157




                                    830k28926113157























                                        12














                                        There are also the following options:



                                        docker container ls
                                        docker container ls -a
                                        # --all, -a
                                        # Show all containers (default shows just running)


                                        since: 1.13.0 (2017-01-18):




                                        Restructure CLI commands by adding docker image and docker container commands for more consistency #26025




                                        and as stated here: Introducing Docker 1.13, users are encouraged to adopt the new syntax:




                                        CLI restructured



                                        In Docker 1.13, we regrouped every command to sit under the logical object it’s interacting with. For example list and start of containers are now subcommands of docker container and history is a subcommand of docker image.



                                        These changes let us clean up the Docker CLI syntax, improve help text and make Docker simpler to use. The old command syntax is still supported, but we encourage everybody to adopt the new syntax.







                                        share|improve this answer



















                                        • 1




                                          great info, a shame that docker --help has the suggested interface 3 pages back in its output, hidden before the deprecated commands!
                                          – danio
                                          Mar 8 '18 at 10:07
















                                        12














                                        There are also the following options:



                                        docker container ls
                                        docker container ls -a
                                        # --all, -a
                                        # Show all containers (default shows just running)


                                        since: 1.13.0 (2017-01-18):




                                        Restructure CLI commands by adding docker image and docker container commands for more consistency #26025




                                        and as stated here: Introducing Docker 1.13, users are encouraged to adopt the new syntax:




                                        CLI restructured



                                        In Docker 1.13, we regrouped every command to sit under the logical object it’s interacting with. For example list and start of containers are now subcommands of docker container and history is a subcommand of docker image.



                                        These changes let us clean up the Docker CLI syntax, improve help text and make Docker simpler to use. The old command syntax is still supported, but we encourage everybody to adopt the new syntax.







                                        share|improve this answer



















                                        • 1




                                          great info, a shame that docker --help has the suggested interface 3 pages back in its output, hidden before the deprecated commands!
                                          – danio
                                          Mar 8 '18 at 10:07














                                        12












                                        12








                                        12






                                        There are also the following options:



                                        docker container ls
                                        docker container ls -a
                                        # --all, -a
                                        # Show all containers (default shows just running)


                                        since: 1.13.0 (2017-01-18):




                                        Restructure CLI commands by adding docker image and docker container commands for more consistency #26025




                                        and as stated here: Introducing Docker 1.13, users are encouraged to adopt the new syntax:




                                        CLI restructured



                                        In Docker 1.13, we regrouped every command to sit under the logical object it’s interacting with. For example list and start of containers are now subcommands of docker container and history is a subcommand of docker image.



                                        These changes let us clean up the Docker CLI syntax, improve help text and make Docker simpler to use. The old command syntax is still supported, but we encourage everybody to adopt the new syntax.







                                        share|improve this answer














                                        There are also the following options:



                                        docker container ls
                                        docker container ls -a
                                        # --all, -a
                                        # Show all containers (default shows just running)


                                        since: 1.13.0 (2017-01-18):




                                        Restructure CLI commands by adding docker image and docker container commands for more consistency #26025




                                        and as stated here: Introducing Docker 1.13, users are encouraged to adopt the new syntax:




                                        CLI restructured



                                        In Docker 1.13, we regrouped every command to sit under the logical object it’s interacting with. For example list and start of containers are now subcommands of docker container and history is a subcommand of docker image.



                                        These changes let us clean up the Docker CLI syntax, improve help text and make Docker simpler to use. The old command syntax is still supported, but we encourage everybody to adopt the new syntax.








                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited Dec 14 '17 at 13:37

























                                        answered Jun 24 '17 at 21:22









                                        tgogos

                                        5,80773677




                                        5,80773677








                                        • 1




                                          great info, a shame that docker --help has the suggested interface 3 pages back in its output, hidden before the deprecated commands!
                                          – danio
                                          Mar 8 '18 at 10:07














                                        • 1




                                          great info, a shame that docker --help has the suggested interface 3 pages back in its output, hidden before the deprecated commands!
                                          – danio
                                          Mar 8 '18 at 10:07








                                        1




                                        1




                                        great info, a shame that docker --help has the suggested interface 3 pages back in its output, hidden before the deprecated commands!
                                        – danio
                                        Mar 8 '18 at 10:07




                                        great info, a shame that docker --help has the suggested interface 3 pages back in its output, hidden before the deprecated commands!
                                        – danio
                                        Mar 8 '18 at 10:07











                                        4














                                        The Docker command set is simple and holds together well:



                                        docker stack ls
                                        docker service ls
                                        docker image ls
                                        docker container ls


                                        Teaching the aliases first is confusing. Once you understand what's going on, they can save some keystrokes:



                                        docker images -> docker image ls
                                        docker ps -> docker container ls
                                        docker rmi -> docker image rm
                                        docker rm -> docker container rm


                                        There are several aliases in Docker. For instance:



                                        docker rmi
                                        docker image rm
                                        docker image rmi
                                        docker image remove


                                        are all the same command (see for your self using docker help image rm).






                                        share|improve this answer




























                                          4














                                          The Docker command set is simple and holds together well:



                                          docker stack ls
                                          docker service ls
                                          docker image ls
                                          docker container ls


                                          Teaching the aliases first is confusing. Once you understand what's going on, they can save some keystrokes:



                                          docker images -> docker image ls
                                          docker ps -> docker container ls
                                          docker rmi -> docker image rm
                                          docker rm -> docker container rm


                                          There are several aliases in Docker. For instance:



                                          docker rmi
                                          docker image rm
                                          docker image rmi
                                          docker image remove


                                          are all the same command (see for your self using docker help image rm).






                                          share|improve this answer


























                                            4












                                            4








                                            4






                                            The Docker command set is simple and holds together well:



                                            docker stack ls
                                            docker service ls
                                            docker image ls
                                            docker container ls


                                            Teaching the aliases first is confusing. Once you understand what's going on, they can save some keystrokes:



                                            docker images -> docker image ls
                                            docker ps -> docker container ls
                                            docker rmi -> docker image rm
                                            docker rm -> docker container rm


                                            There are several aliases in Docker. For instance:



                                            docker rmi
                                            docker image rm
                                            docker image rmi
                                            docker image remove


                                            are all the same command (see for your self using docker help image rm).






                                            share|improve this answer














                                            The Docker command set is simple and holds together well:



                                            docker stack ls
                                            docker service ls
                                            docker image ls
                                            docker container ls


                                            Teaching the aliases first is confusing. Once you understand what's going on, they can save some keystrokes:



                                            docker images -> docker image ls
                                            docker ps -> docker container ls
                                            docker rmi -> docker image rm
                                            docker rm -> docker container rm


                                            There are several aliases in Docker. For instance:



                                            docker rmi
                                            docker image rm
                                            docker image rmi
                                            docker image remove


                                            are all the same command (see for your self using docker help image rm).







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Jun 21 '18 at 20:01









                                            Peter Mortensen

                                            13.5k1983111




                                            13.5k1983111










                                            answered Apr 26 '18 at 17:41









                                            Limited Atonement

                                            4,21623650




                                            4,21623650























                                                0














                                                I got the error message Cannot connect to the Docker daemon. I forgot I am running the daemon as root and needed sudo:



                                                $ sudo docker ps





                                                share|improve this answer



















                                                • 1




                                                  alias docker="sudo --group docker docker"
                                                  – ctrl-alt-delor
                                                  Feb 13 '17 at 18:15


















                                                0














                                                I got the error message Cannot connect to the Docker daemon. I forgot I am running the daemon as root and needed sudo:



                                                $ sudo docker ps





                                                share|improve this answer



















                                                • 1




                                                  alias docker="sudo --group docker docker"
                                                  – ctrl-alt-delor
                                                  Feb 13 '17 at 18:15
















                                                0












                                                0








                                                0






                                                I got the error message Cannot connect to the Docker daemon. I forgot I am running the daemon as root and needed sudo:



                                                $ sudo docker ps





                                                share|improve this answer














                                                I got the error message Cannot connect to the Docker daemon. I forgot I am running the daemon as root and needed sudo:



                                                $ sudo docker ps






                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Mar 16 '17 at 19:43









                                                fduff

                                                2,33312029




                                                2,33312029










                                                answered Jan 22 '16 at 19:52









                                                vezenkov

                                                2,2522024




                                                2,2522024








                                                • 1




                                                  alias docker="sudo --group docker docker"
                                                  – ctrl-alt-delor
                                                  Feb 13 '17 at 18:15
















                                                • 1




                                                  alias docker="sudo --group docker docker"
                                                  – ctrl-alt-delor
                                                  Feb 13 '17 at 18:15










                                                1




                                                1




                                                alias docker="sudo --group docker docker"
                                                – ctrl-alt-delor
                                                Feb 13 '17 at 18:15






                                                alias docker="sudo --group docker docker"
                                                – ctrl-alt-delor
                                                Feb 13 '17 at 18:15













                                                0














                                                Command to get all containers ::



                                                docker ps -a


                                                Command to get running container::



                                                docker ps





                                                share|improve this answer


























                                                  0














                                                  Command to get all containers ::



                                                  docker ps -a


                                                  Command to get running container::



                                                  docker ps





                                                  share|improve this answer
























                                                    0












                                                    0








                                                    0






                                                    Command to get all containers ::



                                                    docker ps -a


                                                    Command to get running container::



                                                    docker ps





                                                    share|improve this answer












                                                    Command to get all containers ::



                                                    docker ps -a


                                                    Command to get running container::



                                                    docker ps






                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered Sep 13 '18 at 13:27









                                                    Archana

                                                    337214




                                                    337214























                                                        0














                                                        There are many ways to list all containers.




                                                        You can find using 3 Aliasesls, ps, list like this.




                                                        sudo docker container ls 
                                                        sudo docker container ps
                                                        sudo docker container list
                                                        sudo docker ps
                                                        sudo docker ps -a


                                                        You can also use give option[option].



                                                        Options -:



                                                          -a, --all             Show all containers (default shows just running)
                                                        -f, --filter filter Filter output based on conditions provided
                                                        --format string Pretty-print containers using a Go template
                                                        -n, --last int Show last created containers (includes all states) (default -1)
                                                        -l, --latest Show the latest created container (includes all states)
                                                        --no-trunc Don't truncate output
                                                        -q, --quiet Only display numeric IDs
                                                        -s, --size Display total file sizes


                                                        You can use an option like this:



                                                        sudo docker ps //Showing only running containers
                                                        sudo docker ps -a //All container (running + stopped)
                                                        sudo docker pa -l // latest
                                                        sudo docker ps -n <int valuse 1,2,3 etc>// latest number of created containers
                                                        sudo docker ps -s // Display container with size
                                                        sudo docker ps -q // Only display numeric IDs for containers
                                                        docker docker ps -a | tail -n 1 //oldest container





                                                        share|improve this answer




























                                                          0














                                                          There are many ways to list all containers.




                                                          You can find using 3 Aliasesls, ps, list like this.




                                                          sudo docker container ls 
                                                          sudo docker container ps
                                                          sudo docker container list
                                                          sudo docker ps
                                                          sudo docker ps -a


                                                          You can also use give option[option].



                                                          Options -:



                                                            -a, --all             Show all containers (default shows just running)
                                                          -f, --filter filter Filter output based on conditions provided
                                                          --format string Pretty-print containers using a Go template
                                                          -n, --last int Show last created containers (includes all states) (default -1)
                                                          -l, --latest Show the latest created container (includes all states)
                                                          --no-trunc Don't truncate output
                                                          -q, --quiet Only display numeric IDs
                                                          -s, --size Display total file sizes


                                                          You can use an option like this:



                                                          sudo docker ps //Showing only running containers
                                                          sudo docker ps -a //All container (running + stopped)
                                                          sudo docker pa -l // latest
                                                          sudo docker ps -n <int valuse 1,2,3 etc>// latest number of created containers
                                                          sudo docker ps -s // Display container with size
                                                          sudo docker ps -q // Only display numeric IDs for containers
                                                          docker docker ps -a | tail -n 1 //oldest container





                                                          share|improve this answer


























                                                            0












                                                            0








                                                            0






                                                            There are many ways to list all containers.




                                                            You can find using 3 Aliasesls, ps, list like this.




                                                            sudo docker container ls 
                                                            sudo docker container ps
                                                            sudo docker container list
                                                            sudo docker ps
                                                            sudo docker ps -a


                                                            You can also use give option[option].



                                                            Options -:



                                                              -a, --all             Show all containers (default shows just running)
                                                            -f, --filter filter Filter output based on conditions provided
                                                            --format string Pretty-print containers using a Go template
                                                            -n, --last int Show last created containers (includes all states) (default -1)
                                                            -l, --latest Show the latest created container (includes all states)
                                                            --no-trunc Don't truncate output
                                                            -q, --quiet Only display numeric IDs
                                                            -s, --size Display total file sizes


                                                            You can use an option like this:



                                                            sudo docker ps //Showing only running containers
                                                            sudo docker ps -a //All container (running + stopped)
                                                            sudo docker pa -l // latest
                                                            sudo docker ps -n <int valuse 1,2,3 etc>// latest number of created containers
                                                            sudo docker ps -s // Display container with size
                                                            sudo docker ps -q // Only display numeric IDs for containers
                                                            docker docker ps -a | tail -n 1 //oldest container





                                                            share|improve this answer














                                                            There are many ways to list all containers.




                                                            You can find using 3 Aliasesls, ps, list like this.




                                                            sudo docker container ls 
                                                            sudo docker container ps
                                                            sudo docker container list
                                                            sudo docker ps
                                                            sudo docker ps -a


                                                            You can also use give option[option].



                                                            Options -:



                                                              -a, --all             Show all containers (default shows just running)
                                                            -f, --filter filter Filter output based on conditions provided
                                                            --format string Pretty-print containers using a Go template
                                                            -n, --last int Show last created containers (includes all states) (default -1)
                                                            -l, --latest Show the latest created container (includes all states)
                                                            --no-trunc Don't truncate output
                                                            -q, --quiet Only display numeric IDs
                                                            -s, --size Display total file sizes


                                                            You can use an option like this:



                                                            sudo docker ps //Showing only running containers
                                                            sudo docker ps -a //All container (running + stopped)
                                                            sudo docker pa -l // latest
                                                            sudo docker ps -n <int valuse 1,2,3 etc>// latest number of created containers
                                                            sudo docker ps -s // Display container with size
                                                            sudo docker ps -q // Only display numeric IDs for containers
                                                            docker docker ps -a | tail -n 1 //oldest container






                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited Nov 20 '18 at 10:59

























                                                            answered Nov 19 '18 at 12:26









                                                            Mr Singh

                                                            1,042723




                                                            1,042723























                                                                -1














                                                                docker ps [OPTIONS]


                                                                Following command will show only running containers by default.



                                                                docker ps


                                                                To see all containers:



                                                                docker ps -a


                                                                For showing the latest created container:



                                                                docker ps -l





                                                                share|improve this answer




























                                                                  -1














                                                                  docker ps [OPTIONS]


                                                                  Following command will show only running containers by default.



                                                                  docker ps


                                                                  To see all containers:



                                                                  docker ps -a


                                                                  For showing the latest created container:



                                                                  docker ps -l





                                                                  share|improve this answer


























                                                                    -1












                                                                    -1








                                                                    -1






                                                                    docker ps [OPTIONS]


                                                                    Following command will show only running containers by default.



                                                                    docker ps


                                                                    To see all containers:



                                                                    docker ps -a


                                                                    For showing the latest created container:



                                                                    docker ps -l





                                                                    share|improve this answer














                                                                    docker ps [OPTIONS]


                                                                    Following command will show only running containers by default.



                                                                    docker ps


                                                                    To see all containers:



                                                                    docker ps -a


                                                                    For showing the latest created container:



                                                                    docker ps -l






                                                                    share|improve this answer














                                                                    share|improve this answer



                                                                    share|improve this answer








                                                                    edited Aug 29 '17 at 16:18







                                                                    user7605325

















                                                                    answered Aug 29 '17 at 15:56









                                                                    Nobita

                                                                    548




                                                                    548























                                                                        -2














                                                                        It is always recommended to add the user in a Docker group.



                                                                        That can be done like:



                                                                        sudo groupadd docker
                                                                        sudo usermod -aG docker $USER --> Equivalent to this you can add the user
                                                                        in /etc/passwd manually.





                                                                        share|improve this answer























                                                                        • Hey any one help me with docker
                                                                          – harkesh kumar
                                                                          Nov 19 '18 at 12:31
















                                                                        -2














                                                                        It is always recommended to add the user in a Docker group.



                                                                        That can be done like:



                                                                        sudo groupadd docker
                                                                        sudo usermod -aG docker $USER --> Equivalent to this you can add the user
                                                                        in /etc/passwd manually.





                                                                        share|improve this answer























                                                                        • Hey any one help me with docker
                                                                          – harkesh kumar
                                                                          Nov 19 '18 at 12:31














                                                                        -2












                                                                        -2








                                                                        -2






                                                                        It is always recommended to add the user in a Docker group.



                                                                        That can be done like:



                                                                        sudo groupadd docker
                                                                        sudo usermod -aG docker $USER --> Equivalent to this you can add the user
                                                                        in /etc/passwd manually.





                                                                        share|improve this answer














                                                                        It is always recommended to add the user in a Docker group.



                                                                        That can be done like:



                                                                        sudo groupadd docker
                                                                        sudo usermod -aG docker $USER --> Equivalent to this you can add the user
                                                                        in /etc/passwd manually.






                                                                        share|improve this answer














                                                                        share|improve this answer



                                                                        share|improve this answer








                                                                        edited Jun 21 '18 at 20:01









                                                                        Peter Mortensen

                                                                        13.5k1983111




                                                                        13.5k1983111










                                                                        answered May 4 '18 at 5:54









                                                                        Prateek patel

                                                                        12




                                                                        12












                                                                        • Hey any one help me with docker
                                                                          – harkesh kumar
                                                                          Nov 19 '18 at 12:31


















                                                                        • Hey any one help me with docker
                                                                          – harkesh kumar
                                                                          Nov 19 '18 at 12:31
















                                                                        Hey any one help me with docker
                                                                        – harkesh kumar
                                                                        Nov 19 '18 at 12:31




                                                                        Hey any one help me with docker
                                                                        – harkesh kumar
                                                                        Nov 19 '18 at 12:31


















                                                                        draft saved

                                                                        draft discarded




















































                                                                        Thanks for contributing an answer to Stack Overflow!


                                                                        • Please be sure to answer the question. Provide details and share your research!

                                                                        But avoid



                                                                        • Asking for help, clarification, or responding to other answers.

                                                                        • Making statements based on opinion; back them up with references or personal experience.


                                                                        To learn more, see our tips on writing great answers.





                                                                        Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                                        Please pay close attention to the following guidance:


                                                                        • Please be sure to answer the question. Provide details and share your research!

                                                                        But avoid



                                                                        • Asking for help, clarification, or responding to other answers.

                                                                        • Making statements based on opinion; back them up with references or personal experience.


                                                                        To learn more, see our tips on writing great answers.




                                                                        draft saved


                                                                        draft discarded














                                                                        StackExchange.ready(
                                                                        function () {
                                                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16840409%2fhow-to-list-containers-in-docker%23new-answer', 'question_page');
                                                                        }
                                                                        );

                                                                        Post as a guest















                                                                        Required, but never shown





















































                                                                        Required, but never shown














                                                                        Required, but never shown












                                                                        Required, but never shown







                                                                        Required, but never shown

































                                                                        Required, but never shown














                                                                        Required, but never shown












                                                                        Required, but never shown







                                                                        Required, but never shown







                                                                        Popular posts from this blog

                                                                        MongoDB - Not Authorized To Execute Command

                                                                        How to fix TextFormField cause rebuild widget in Flutter

                                                                        in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith