> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/demisto-sdk-development-guide/demisto-sdk-guide/demisto-sdk-usage-and-configuration/run-the-demisto-sdk-in-a-docker-container.md).

# Run the Demisto SDK in a Docker container

Run Demisto SDK validations from within a Docker container.

Use the Docker image to run Demisto SDK commands locally or as a CI/CD process.

{% hint style="warning" %}

### Prerequisites

* To use the Demisto SDK, create a content repository for Cortex XSOAR content in a structure that matches the official [Cortex XSOAR content repository](https://github.com/demisto/content).

  You can generate your repository from this [template](https://github.com/demisto/content-external-template).
* The Demisto SDK uses volume mounts to run on the local content repository, which may cause slowness on macOS or Windows. To optimize performance use one of the following:
  * A Linux machine
  * [Windows WSL2](https://docs.microsoft.com/en-us/windows/wsl/install)
    {% endhint %}

#### Get the Docker image

Pull the Docker image with `docker pull demisto/demisto-sdk:<tag>` .

The latest tags are in the Docker hub [here](http://hub.docker.com/r/demisto/demisto-sdk).

**Environment variables**

Some commands such as `demisto-sdk upload` and `demisto-sdk run` need the following environment variables to communicate with your Cortex XSOAR server.

| Environment Variable | Description                         |
| -------------------- | ----------------------------------- |
| `DEMISTO_BASE_URL`   | The URL of the Cortex XSOAR server. |
| `DEMISTO_API_KEY`    | The API key.                        |
| `DEMISTO_VERIFY_SSL` | Whether to verify SSL certificates. |

To pass the variables, do one of the following:

* Add the `--env` option, for example:

  ```programlisting
  docker run --env DEMISTO_BASE_URL="https://xsoar.com:443" <rest of the command>
  ```
* Use an `.env` file, for example:

  ```programlisting
  DEMISTO_BASE_URL="https://xsoar.com:443"
  DEMISTO_API_KEY="xxxxxxxxxxxxx"
  ```

  Pass the variables with the following command:

  ```programlisting
  docker run --env-file .env <rest of the command>
  ```

#### Run Docker-in-Docker (Docker Daemon binding)

Docker-in-Docker involves running Docker within a Docker container. Instead of interacting with the host's Docker daemon, a new Docker engine is spawned within a container, providing an isolated environment for managing containers and images. It enables creating isolated, reproducible, and secure environments within Docker containers.

To use Docker commands from within a container, you need to mount the host's Docker daemon socket as follows:

```programlisting
--mount source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind
```

#### Command arguments

| `docker run`                                                                | Creates a container (if one does not exist) and runs the following command inside it.                                                                                       |
| --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-it`                                                                       | Keeps the `stdin` open and connects `tty`.                                                                                                                                  |
| `--rm`                                                                      | Removes the Docker container when done (omit this to reuse the container in the future).                                                                                    |
| `--mount type=bind,source="$(pwd)",target=/content`                         | Connects the `pwd` (if you're in `content`) to the container's `content` directory.                                                                                         |
| `--mount source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind` | Binds the Docker daemon socket to the container to enable running Docker- in- Docker.                                                                                       |
| `demisto/demisto-sdk:\<tag>`                                                | <p>The Docker image name.</p><p>Replace the tag with the locked version, it can be found in the <a href="https://hub.docker.com/r/demisto/demisto-sdk">Docker Hub</a>).</p> |
| `demisto-sdk validate -i Packs/ipinfo/Integrations/ipinfo_v2`               | The Demisto SDK command to run inside the container.                                                                                                                        |

**Create an alias to a command**

Creating an alias to a command makes it easier to use the command. You can do this by adding the following line to your shell configuration files:

*Example*

```programlisting
alias demisto-sdk="docker run -it --rm \
--mount type=bind,source="$(pwd)",target=/content \
--mount source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind \
demisto/demisto-sdk:<tag>"
```

**Use the validate command**

For more information about the `validate` command, see [validate](/demisto-sdk-development-guide/demisto-sdk-guide/demisto-sdk-commands/validate.md).

*Example*

```programlisting
docker run -it --rm \
--mount type=bind,source="$(pwd)",target=/content \
--mount source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind \
demisto/demisto-sdk:<tag> \
demisto-sdk validate -i Packs/ipinfo/Integrations/ipinfo_v2
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cortex-docs.paloaltonetworks.com/demisto-sdk-development-guide/demisto-sdk-guide/demisto-sdk-usage-and-configuration/run-the-demisto-sdk-in-a-docker-container.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
