6

Hi i am new user on ubuntu during my practice i install docker by

sudo apt install docker.io

Check the version and all thing properly i started working after it i pull the ubuntu image by

sudo docker pull ubuntu

after it i check the image by

sudo docker images

image is shown by all details after that i make the container by

sudo docker container run -it ubuntu /bin/bash

when i try to see my container by

sudo docker ps

the result is blank

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

But when i write this command

sudu docker ps -a

this shows me the container

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                    PORTS               NAMES
110359388f2d        ubuntu              "/bin/bash"         21 hours ago        Exited (0) 21 hours ago                       stupefied_dewdney

How to fix this? Why my container is not showing in docker ps ?

Eva
  • 61
  • 1
  • 1
  • 2
  • 2
    Does this answer your question? [How to list containers in Docker](https://stackoverflow.com/questions/16840409/how-to-list-containers-in-docker) – tgogos Feb 12 '20 at 12:35
  • once you get the answer kindly accept the answer so that this will help others – anand Feb 12 '20 at 12:38

2 Answers2

8

So there is a difference between docker ps and docker ps -a

docker ps: shows the running container on your host
docker ps -a: this shows running and exited containers on the host.

So in your case your container is exited, means not running on the host thats why this shows in docker ps -a

anand
  • 741
  • 5
  • 11
1

It's not showing as the container has exited.

docker ps only shows running containers while passing the -a flag shows all containers. If you want your container to show up, you will have to start it by using docker container start

Ghonima
  • 2,978
  • 2
  • 14
  • 23
  • 2
    if container has single command it will stop and again `docker ps` will show nothing – d0niek Feb 12 '20 at 12:37
  • @d0niek thank you soo much when i run the container by sudo docker container run -it ubuntu /bin/bash bash: /root/.bashrc: Permission denied root@c3c0fbd35bd9:/# thisis showing – Eva Feb 12 '20 at 12:53