docker ps (or docker container ls) lists containers. docker image ls lists images.
A container is created based on an image. An image does never run - it is just the packaging and delivery artifact.
Please share how you start the container: the exact command, or if docker compose is used the content of the compose file.
First I try to build and run the docker using below commands,
Build the image - docker buid -t test .
Running the container :docker run -t test
docker ps → no running containers
docker ps -a → Will see the conatiner Id and image
docker exec -it container_id cmd
If this does not show the container, then trying to exec into it can’t work.
What does docker ps -a indicate as error or exit code?
Apparently your build creates an image that either has an error or does not keep the container running. A container is just an isolated process; if the process stops, the container stops.
docker ps -a → indicates my container exited after 11 secs of creation.
PS C:> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0e2bfab6e7b7 evasvc “powershell Start-Se…” 20 seconds ago Exited (0) 9 seconds ago elegant_ritchie
Not sure why it gets exited every time after few secs of creation. During build I dont get any warning/error.
Exit Code 0 means the application ended without an error. Is it possible your application is not designed as permanent running processes? It will not work if your command returns the prompt immediately and then start background processing.
You can use docker ps -a --no-trunc to prevent the output from being truncated.