Unable to run docker image inside Container

Hi All,

I am new to docker, I am trying to run windows service inside container.

This is my sample code which I follow.

Use an official Microsoft runtime as a parent image

FROM Microsoft Artifact Registry

SHELL [“powershell”, “-Command”, “$ErrorActionPreference = ‘Stop’; $ProgressPreference = ‘SilentlyContinue’;”]

Copy the solution file

COPY “Sample/bin/Debug” C:\Service

ENTRYPOINT [“powershell”]
CMD [“C:\Service\MyService.exe”];

When I tried using docker ps, my docker image is not running.
When I execute the container, I am getting below error

Error response from daemon: Container ad20a5b9169aacb3a76c2b0f213abcc65f5356dca2165df71c12c426b91ac680 is not running

I may be lame please do help me on this problem.

I have no experience with Windows containers, though I stumbled across the topic title, as it doesn’t really make sense.

You seem to build an image and try to run a container from that image, though how is this “Unable to run docker image inside Container”.

Have you tried to check docker container logs for the container?

Yes, I dont see any docker logs, its getting exited within 14 secs. When I try to check using docker ps, I dont see my docker image in the list.

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

These are the commands I try in powershell

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
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.