Ubuntu docker image is not running in the detached mode

Viewed 599

I created one image using below Dockerfile

FROM ubuntu:latest
RUN mkdir -p /app   
COPY . /app         
CMD python /app/app.py

I am using this command to build the image:

DOCKER_BUILDKIT=1 docker build -t my-first-ubuntu-image .

And this one to run the container

Command for running the container : docker container run -d my-first-ubuntu-image

And when I run docker ps -a*, its status is showing Exited.
What is going on? I cannot understand because when I did the same for a nginx image, it is in running state.

1 Answers

There is a trick to prevent the container from dying: docker run -d my_image -d tail /dev/null -f

The command tail /dev/null -f keeps the container busy forever.

Related