# Basic Docker Commands

![](/files/-MEQy19061GcixBCtQAF)

When we run docker run ubuntu command . It runs an instance of Ubuntu image & exits immediately. If we want to see the list of running containers we not able to. As we can see above after executing docker ps -a it showing it exited . Now question is why is that ??

a) Unlike VMs containers are not meant to host the operating systems . Conatiners are meant to run a specific task of process such a to host an instance of a WebServer , application server , a database or simply to carry some kind of computations or analysis task . Once the task is completed the container exits. A container only lives as long as the process inside it is alive . If the webservice inside the container is stopped or crashed then container exits. This is why the Ubuntu container that we run stops immediately . Bcoz Ubuntu is just an image of an operating system that is used as the base image for other applications . There is no application or process running inside it by default .

\>>>If the image is not running any service as in case of Ubuntu we could instruct Docker to run a process with the docker run command . For example a sleep command with a duration of 5 seconds shown below.

![](/files/-MER-HukOj06zWS5-K1R)

We can run our Docker container in detach mode that means it will run permanently in the background.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://architectures.gitbook.io/project/docker/docker-commands/basic-docker-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
