# Detecting Docker

The DCli api allows you to detect if you are running in a Docker container

## DockerShell

DCli has the ability to detect which shell (bash, powershell, zsh etc) that you are running under.

If you DCli app is used as the Docker ENTRYPOINT then your parent won't be a shell.

In this case calling Shell.current will return a DockerShell:

```dart
DockerShell shell = Shell.current;
```

Attributes of DockerShell.

* shell name is 'docker'
* loggedInUser = 'root'
* isPrivilegedUser will always be true

## Detecting if you are running in a Docker

Using DockerShell to detect if you are in a Docker container is not reliable as in some circumstances you DCli app will be run from within a standard shell (bash etc) within Docker

Instead use:

```dart
if (DockerShell.inDocker)
{
    /// do something docker
}
```

This method looks for the presence of /.dockerenv which Docker guarantee will exist.


---

# 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://dcli.onepub.dev/dcli-api/cross-platform/docker/detecting-docker.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.
